How can I separate two connected objects in a binary image using a free hand drawing tool?
9 views (last 30 days)
Show older comments
Hello. I did some watershedding segmentation for an image with several objects. I used regionprops to make a list of objects. that worked quite well, but there are some touching objects that got counted as a single object. I would like to separate them manually. Is there an easy way to draw on top of a binary image to separate the objects? Or I could use something where I can click to change the value of a pixel from 1 to 0.
I tried using imfreehand, but I don't want to segment each object individually
0 Comments
Answers (1)
Rahul
on 25 Nov 2024 at 5:34
In order to separate connected objects from a binary image using free hand tool, consider using 'impoly' or 'drawpolygon' or 'drawfreehand' functions which can be used to define the area of the image to segment by the user along 'wait' to register the region. 'createmask' function can be used to create a binary mask of the defined region. Please refer to the below example for the same:
% Assuming 'image' to be the variable containing the image after being read
h = impoly;
position = wait(h);
mask = createMask(h);
image(mask) = 0; % Can be adjusted according to requirement
The following MATLAB Answers also present approaches to segment and separate objects from images:
https://www.mathworks.com/matlabcentral/answers/861390-how-to-separate-objects-in-image-using-matlab
For more information, you can refer to the MathWorks documentation links below:
'drawpolygon': https://www.mathworks.com/help/images/ref/drawpolygon.html
'drawfreehand': https://www.mathworks.com/help/images/ref/drawfreehand.html
Thanks.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!