How can I separate two connected objects in a binary image using a free hand drawing tool?

9 ビュー (過去 30 日間)
Benjamin Brenner
Benjamin Brenner 2020 年 10 月 12 日
回答済み: Rahul 2024 年 11 月 25 日 5:34
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

回答 (1 件)

Rahul
Rahul 2024 年 11 月 25 日 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:
For more information, you can refer to the MathWorks documentation links below:
Thanks.

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by