Grid detection of irregular objects
Show older comments
I would like to fit the holes in the following image to extract the holes' centers, the angle of rotation for the image (the angle in this image happens to be small), and the radii of the holes if they're fit to circles:

After perusing for solutions, I've realized that I'm not able to make much progress without converting this image to black and white, so I've done that:

It seems that detectCircleGridPoints with the asymmetric argument will be the way to go, but I can neither get it to detect any of the objects (perhaps since they're not perfect circles) nor to return the angle of rotation for the image or radii of the detected circles. Any advice for utilizing detectCircleGridPoints or some other approach for acquiring the centers, angle of rotation, and radii would be greatly appreciated! Here is my code:
% Read image
I = imread('rawimage.png');
% Convert image to bw
I = imbinarize(rgb2gray(I), 'adaptive', 'ForegroundPolarity', 'bright', 'Sensitivity', 0.5);
I = imopen(I, strel('disk', 5));
I = imfill(I,'holes');
I = bwareaopen(I, 1000);
I = im2uint8(I);
% Apply grid fit
patternDims = [4, 17];
imagePoints = detectCircleGridPoints(I,patternDims,PatternType="asymmetric");
% Visualize results
J = insertText(I,imagePoints,1:size(imagePoints,1));
J = insertMarker(J,imagePoints,'x',Color="green",Size=5);
imshow(J)
title("Detected a Circle Grid of Dimensions " + mat2str(patternDims))
Accepted Answer
More Answers (0)
Categories
Find more on Computer Vision with Simulink 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!