Recognizing a Specific Figure in an Image
7 views (last 30 days)
Show older comments
I'm using roipoly to select a specific section of a graph. Afterwards, I subtract the two images to find contrast giving me something like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/447208/image.jpeg)
How might I write code that can recognize the black circle (within the roipoly region)?/Is it impossible and/or greatly inefficient to do this without modifying the image further (like removing the axes)?
As a side note, the region select may not be a perfect polygon (ie it can be any random polygon)
0 Comments
Answers (2)
Shraddha Jain
on 23 Dec 2020
Hi Gabrielle,
There is a function imfindcircles in Image Processing Toolbox which can find circles in an image using Hough transform. Further, you can also investigate the function regionprops and the example given in its documentation on spotting circular objects in an image.
Hope this helps!
0 Comments
Image Analyst
on 23 Dec 2020
Gabrielle, exactly what does "recognize" mean to you? You call regionprops() to get the centroid, area, or other measurements;
mask = yourImage == 0; % Find black
mask = imclearborder(mask); % Get rid of surround.
mask = imfill(mask, 'holes'); % Fill holes.
mask = bwareafilt(mask, 1); % Take largest ellipse only.
props = regionprops(mask, 'Centroid', 'Area');
area = props.Area
xCenter = props.Centroid(1)
yCenter = props.Centroid(2)
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!