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))

 채택된 답변

Image Analyst
Image Analyst 2022년 7월 2일

0 개 추천

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')
As far as getting the angle of the rows of dots, you can use radon. Demo attached.
Write back if you still need help.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

질문:

2022년 7월 2일

답변:

2022년 7월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by