这是首发... 使用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);
最后一部分是真正的“快速和肮脏的”,我敢肯定,随着这些工具,你已经使用过,你会得到更好的结果...
来源
2012-11-15 22:59:29
bla
它看起来像你有三峰直方图。查看我在dsp.stackexchange.com上的答案 - > http://dsp.stackexchange.com/questions/3643/image-segmentation-issue-of-different-materials/3650#3650。无论如何,你的问题应该被移到该网站。 –
我试过基于直方图的分割。这种方法的问题在于,最右侧群集周围的像素值与最左侧群集的像素最相似,导致最右侧群集周围出现“晕圈”。 – Richard
你有没有试过bwboundaries,或者bwlabel?他们可能会为你工作。但是如果光环效应太大,你可能得不到你想要的结果。尽管如此,通过一些操作和清理之前和之后,你可能会得到你想要的。它也可能有助于使用像[hough circles](http://www.mathworks.com/matlabcentral/fileexchange/26978-hough-transform-for-circles/content/html/circle_houghdemo.html)或其他方法[这一个](http://blogs.mathworks。com/pick/2008/05/23/detected-circles-in-an-image /),以便你知道你的圈子的界限。 – Bill