Matlab中标记控制的分水岭中的过度分割 [英] Over-segmentation in the marker controlled watershed in Matlab

查看:444
本文介绍了Matlab中标记控制的分水岭中的过度分割的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Matlab中实施标记控制的分水岭时遇到问题.

I have a problem while implementing the marker controlled watershed in Matlab.

输入图像是具有两个聚类对象的二进制掩码. 另一幅图像是另一幅二进制图像,其中白色区域指示标记.

The input image is a binary mask which have two clustered object. An other image is an other binary image where the white regions indicate the markers.

然后,我尝试使用标记控制的分水岭来拆分群集对象.代码如下:

Then I try to use the marker controlled watershed to splitting the clustered object. The code is as follows:

bw=imread('Im.jpg'); % read image
bwMarker=imread('Marker.jpg');% read marker
bw(bwMarker)=0; % impose the marker on the image
L=watershed(bw);% do the watershed
%% plot
rgb = label2rgb(L,'jet',[.5 .5 .5]);
figure(2), imshow(rgb,'InitialMagnification','fit')
title('Marker Controlled Watershed transform ')

结果显示为该图.


它将对象分成两部分,但是形状并不完整.我想得到整个对象,但只用一条线将两者分开(如下所示),有人可以帮我吗?谢谢.


It splits the object into two, but the shape is not intact. I want to get the whole object but just a line splitting the two (as shown below) Can anybody help me out? Thanks.

附加问题: 谢谢yoda提供的答案.但是,在这种情况下,使用"cityblock"进行距离转换是好的,但是如果使用"euclidean",则会导致过度分割.因为分水岭将取决于图像中的局部最小值,并且巧合的是,"cityblock"距离变换导致正确数量的局部最小值.如果我们将"cityblock"应用于其他图像,也会导致过度分割. 现在,让我们看一下yoda的代码:

Appended question: Thank you for yoda provides the answer. However, in this case, the distance transform using 'cityblock' is good but if we using 'euclidean' it will lead to over segmentation. Because the watershed will depend on the local minimums in the image and it is coincident that the 'cityblock ' distance transform result in correct number of local minimums. If we apply the 'cityblock' for other image, it will lead to over segmentation as well. Now let's see yoda's code:

img=im2bw(imread('http://i.stack.imgur.com/qrYCL.jpg'));

imgDist=-bwdist(~img,'cityblock');
imgDist(~img)=-inf; 

% check local minimums
BW = imregionalmin(imgDist);
figure(1), imshow(BW);  
title('Regional Minima in Original Image');

imgLabel=watershed(imgDist); 

局部最小值和结果如下所示:

The local minimums and the result are shown as follows:

请注意,在左图中,局部最小值显示为白色区域.可以观察到,在聚类对象中仅显示了两个局部最小值.这样可以带来良好的结果.

Note that in the left figure, the local minimum are show as white regions. It is observed that only two local minimum shown in the clustered objects. So leads to the good results.

现在让我们看一下使用欧几里得"的距离变换.

Now let's take a look at the distance transform by using 'euclidean'.

imgDist=-bwdist(~img);
imgDist(~img)=-inf; 

% check local minimums    
BW = imregionalmin(imgDist);
figure(1), imshow(BW);  
title('Regional Minima in Original Image');

imgLabel=watershed(imgDist);    

imshow(imgLabel==0,'InitialMagnification','fit')

局部最小值和结果如下所示:

The local minimums and the result are shown as follows:

请注意,在左图中,局部最小值显示为白色区域.可以观察到,在聚类对象区域中显示了许多局部最小值.因此,这导致了结果的过度细分.

Note that in the left figure, the local minimum are show as white regions. It is observed that there are many local minimum shown in the clustered objects region. So this leads to the over-segmented results.

过度分割是因为分水岭将首先检查图像中的局部最小值,然后基于局部最小值执行分水岭.请注意,如果局部最小值比所需的分割对象太多,则会导致过度分割.提出了标记控制的分水岭,以取代原始的局部最小值并获得更好的结果(因为每个标记将代表一个所需的分割对象).但是我不知道如何强加标记",以便降低原始的局部最小值,并且图像仅具有由标记"指定的局部最小值.谢谢.

The over segmentation is because the watershed will first check out the local minimums in the image, then base on the local minimums, perform the watershed. Note that if there are too many local minimums than the desired segmented objects, it will lead to over segmentation. The marker controlled watershed is proposed to replace the original local minimums and achieve better result(since each marker will represent one desired segmented object). But I don't know how to impose the 'marker' so that the original local minimums are depressed and the image only have the local minimums specified by the 'marker'. Thanks.

推荐答案

解决方案2:使用基于标记的分水岭:

您可以使用功能imimposemin强制将局部最小值设置为标记所在的位置.您需要通过使用

Solution 2: Using marker based watershed:

You can use the function imimposemin to force the local minima to be where your markers are. You'll need to slighty modify the code in solution 1 below by replacing the first imDist... line with

imgDist=-bwdist(~img);
imgDist=imimposemin(imgDist,marker);

其余代码相同.您应该按如下所示进行细分:

The rest of the code is the same. You should get the segmentation as follows:

这是MATLAB中的解决方案,可将您的两个群集分开:

Here is a solution in MATLAB that separates your two clusters:

img=im2bw(imread('http://i.stack.imgur.com/qrYCL.jpg'));

imgDist=-bwdist(~img,'cityblock');
imgDist(~img)=-inf;    
imgLabel=watershed(imgDist);    

imshow(imgLabel==0,'InitialMagnification','fit')

这篇关于Matlab中标记控制的分水岭中的过度分割的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆