Grid detection of irregular objects
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Cole Meyer
le 2 Juil 2022
Réponse apportée : Image Analyst
le 2 Juil 2022
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))
0 commentaires
Réponse acceptée
Image Analyst
le 2 Juil 2022
Not sure which of your poorly-named variables is your binary image mask, but you can use regionprops on it to get the equivalent circular diameter and the centroid.
mask = bwconvhull(mask, 'Objects'); % Take convex hull to get rid of dents in the perimeters.
props = regionprops(mask, 'EquivDiameter', 'Centroid')
Write back if you still need help.
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!