Over-segmentation in the marker controlled watershed in Matlab

前端 未结 2 1351
孤街浪徒
孤街浪徒 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

    0 讨论(0)
  • 2021-02-15 17:49

    This is how I would do this in Mathematica. Hope you can translate.

    i1 = Binarize@Import["http://i.stack.imgur.com/qrYCL.jpg"];
    marker = Binarize@Import[  "http://i.stack.imgur.com/CMI6Z.jpg"]; 
    
    ImageMultiply[i1, WatershedComponents[i1, marker] // Colorize]
    

    enter image description here

    0 讨论(0)
提交回复
热议问题