Over-segmentation in the marker controlled watershed in Matlab

前端 未结 2 1349
孤街浪徒
孤街浪徒 2021-02-15 17:41

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 oth

2条回答
  •  不思量自难忘°
    2021-02-15 17:45

    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:

    enter image description here


    Solution 1: Using Manhattan distance:

    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')
    

    enter image description here

提交回复
热议问题