matlab - 分割灰度图像

标签 matlab image-processing image-segmentation morphological-analysis mathematical-morphology

我无法正确分割灰度图像:

Image to be segmented

基本事实,即我希望分割的样子,是这样的:

Ground truth

我最感兴趣的是圈内的三个组成部分。因此,如您所见,我想将顶部图像分割成三个部分:两个半圆和它们之间的一个矩形。

我尝试了膨胀、腐 eclipse 和重建的各种组合,以及各种聚类算法,包括 k-means、isodata 和混合高斯——所有这些都取得了不同程度的成功。

如有任何建议,我们将不胜感激。

编辑:这是我能够获得的最好结果。这是使用事件轮廓分割圆形 ROI,然后应用等数据聚类获得的:

Clusters

这有两个问题:

  • 右下星团周围的白色光晕,属于左上星团
  • 右上角和左下角簇周围的灰色光晕属于中心簇。

最佳答案

这是一个开始... 使用 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.');

enter image description here

只选择圆圈内的内容:

 [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);

enter image description here

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

 bw2=(bw<1.*f);

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

 bw2= medfilt2(medfilt2(bw2));

我们一起得到:

 imagesc(bw+3*bw2); 

enter image description here

最后一部分是真正的“快速而肮脏”,我相信使用您已经使用过的工具,您会获得更好的结果...

关于matlab - 分割灰度图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13403024/

相关文章:

c++ - 在 C++ 程序中使用 mat 文件

python - MATLAB 的直方图均衡有什么问题?

tensorflow - 喀拉斯/TF 错误 : Incompatible shapes

python - 如何用白色填充闭合轮廓区域

matlab - Simulink 仿真的行为与使用 rk4 的相同仿真有很大不同

matlab - 多类朴素贝叶斯分类器 : Getting Same Error Rate

algorithm - 图像调色板减少

python - cv2.addWeighted 除了一些颜色

javascript - 使用适用于 Zebra 打印机的 PHP 或 Javascript 将 RGB 图像转换为 Floyd-Steinberg 图像

从二维点列表中检测曲线的算法