Radius and coordinates of the center for a big circle in a bidimensional image
1 回表示 (過去 30 日間)
古いコメントを表示
I have a bidimensional (N x N) matrix of pixels like the one shown in the attached figure. Black areas contain zero values, while other areas contain random non-zero values. How could I determine the radius (in pixels) and coordinates of the center for the big circle? Consider that its center doesn't correspond to the center of the matrix, like in the figure.

0 件のコメント
採用された回答
Image Analyst
2016 年 2 月 11 日
編集済み: Image Analyst
2016 年 2 月 11 日
Get a binary image by thresholding. Then fill holes, label, and call regionprops().
binaryImage = grayImage > 10; % or whatever value works.
% Fill holes
binaryImage = imfill(binaryImage, 'holes');
% Label
labeledImage = bwlabel(binaryImage);
% Measure
measurements = regionprops(labeledImage, 'EquivDiameter');
% Extract
theRadius = measurements.EquivDiameter / 2;
By the way, instead of the very verbose and overly complicated "bidimensional (N x N) matrix of pixels", most people would simply just say "2D image".
その他の回答 (1 件)
Anand
2016 年 2 月 11 日
Here's some code that should help:
% Read the image
I = imread('http://www.mathworks.com/matlabcentral/answers/uploaded_files/45140/figformatlab.png');
% Find circles in the image
radiusRange = [20 30]; % You need an approximate range of what you expect the radius to be.
[centers,radii] = imfindcircles(I, radiusRange, 'ObjectPolarity', 'dark','Sensitivity',.9);
% Display found circles
imshow(I)
viscircles(centers,radii);
The variables centers and radii hold what you are looking for.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!