How to select a region if we click inside it?
Show older comments
Dear all,
I have a binary image same as the one I show here which contains few honeycomb regions connected to each other. Now I want a single honeycomb to be selected when the user makes a left click using the mouse inside the desired honeycomb. Any idea how

to do that?
Any suggestions will be appreciated.
Sincerely, Mueshoo
Accepted Answer
More Answers (1)
Image Analyst
on 15 Jan 2014
0 votes
Mustafa: Here's how to do it step by step:
- invert the image
- call imclearborder
- label the binary image with bwlabel
- call [column, row] = int32(ginput(1)) to let the user click somewhere
- get the label with labelNumber = labeledImage(row, column)
- extract the object with extractedObject = ismember(labeledImage, labelNumber)
- Make it binary again binaryImage = extractedObject > 0;
- display it with imshow(binaryImage, []);
See if you can program that up and attach your code if you have problems.
6 Comments
Meshooo
on 15 Jan 2014
Meshooo
on 15 Jan 2014
YEIMY LISETH QUINTANA VILLAMIZAR
on 20 Oct 2016
help me, please.
I used this code but I need that the program show me the object in color the original image.
Have you any idea?
Image Analyst
on 21 Oct 2016
Try this
labeledImage = bwlabel(binaryImage, 8); % Label each blob so we can make measurements of it
% labeledImage is an integer-valued image where all pixels in the blobs have values of 1, or 2, or 3, or ... etc.
% Let's assign each blob a different color to visually show the user the distinct blobs.
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); % pseudo random color labels
imshow(coloredLabels);
YEIMY LISETH QUINTANA VILLAMIZAR
on 23 Oct 2016
Can you help me? please,
I need that the program recognize a image of another image, loading a image that is a circle and loading other that is a ellipse.
How I can make that the program recognize that the image is a circle or a ellipse ?
Image Analyst
on 24 Oct 2016
See my shape recognition demo, attached.
Categories
Find more on Language Support in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!