Recognizing a Specific Figure in an Image

조회 수: 5(최근 30일)
Gabrielle Kang
Gabrielle Kang 2020년 12월 5일
답변: Image Analyst 2020년 12월 23일
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:
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)


Shraddha Jain
Shraddha Jain 2020년 12월 23일
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!

Image Analyst
Image Analyst 2020년 12월 23일
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)

Community Treasure Hunt

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

Start Hunting!

Translated by