matlab灰度图像分割标记,matlab – 分割灰度图像

这是一个首发……

使用

circular Hough transform找到圆形部分.为此我最初是

threshold the image locally.

im=rgb2gray(imread('Ly7C8.png'));

imbw = thresholdLocally(im,[2 2]); % thresold localy with a 2x2 window

% preparing to find the circle

props = regionprops(imbw,'Area','PixelIdxList','MajorAxisLength','MinorAxisLength');

[~,indexOfMax] = max([props.Area]);

approximateRadius = props(indexOfMax).MajorAxisLength/2;

radius=round(approximateRadius);%-1:approximateRadius+1);

%find the circle using Hough trans.

h = circle_hough(edge(imbw), radius,'same');

[~,maxIndex] = max(h(:));

[i,j,k] = ind2sub(size(h), maxIndex);

center.x = j; center.y = i;

figure;imagesc(im);imellipse(gca,[center.x-radius center.y-radius 2*radius 2*radius]);

title('Finding the circle using Hough Trans.');

只选择圈内的内容:

[y,x] = meshgrid(1:size(im,2),1:size(im,1));

z = (x-j).^2+(y-i).^2;

f = (z<=radius^2);

im=im.*uint8(f);

编辑:

寻找一个开始阈值的地方,通过查看直方图来分割图像,找到它的第一个局部最大值,并从那里迭代直到找到2个单独的段,使用bwlabel:

p=hist(im(im>0),1:255);

p=smooth(p,5);

[pks,locs] = findpeaks(p);

bw=bwlabel(im>locs(1));

i=0;

while numel(unique(bw))<3

bw=bwlabel(im>locs(1)+i);

i=i+1;

end

imagesc(bw);

现在可以通过从圆圈中取出两个标记的部分来获得中间部分,剩下的将是中间部分(一些光环)

bw2=(bw<1.*f);

但经过一些中值滤波后,我们得到了更合理的东西

bw2= medfilt2(medfilt2(bw2));

我们一起得到:

imagesc(bw+3*bw2);

最后一部分是一个真正的“快速和肮脏”,我敢肯定,使用你已经使用的工具,你会得到更好的结果……

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值