Finding average radius of a binarized image of a circle
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Patrick Schneider
el 17 de Jul. de 2020
Respondida: KSSV
el 17 de Jul. de 2020
I have several images of XY projections of a computer reconstructed sphere, all of which have been binarized for easier calculations and look like the image below
I know I can import the image as an array of 0's and 1's, but I was wondering if there was an easy way to calculate the radius with a given angle theta if the center point of the image is known. My end goal is simply to find the average radius of the whole circle, but I am slightly confused as to how angles and radii would work when an image is made up of discreet pixels.
0 comentarios
Respuesta aceptada
Image Analyst
el 17 de Jul. de 2020
If you just want the equivalent circular diameter, you can ask regionprops().
props = regionprops(mask, 'EquivDiameter');
ECD = props.EquivDiameter; % Equivalent Circular Diameter - diameter of a circle with the same number of pixels as your blob.
If you want radius as a function of angle, then that's more complicated and involves using regionprops to find the centroid, bwboundaries() to find the outline, atan2d() to find the angle, and sqrt() to find the distance (radius) at that angle.
0 comentarios
Más respuestas (1)
KSSV
el 17 de Jul. de 2020
I = imread("image.png") ;
I1 = rgb2gray(I) ;
I1(I1==1) = 0 ;
I1(I1>0) = 1 ;
[y,x] = find(I1) ;
% Get center of circle
C = [mean(x) mean(y)] ;
% Get raidus of circle
r = sqrt((C(1)-x).^2+(C(2)-y).^2) ;
R = max(r) ;
th = linspace(0,2*pi) ;
xc = C(1)+R*cos(th) ; yc = C(2)+R*sin(th) ;
% plot
imshow(I)
hold on
plot(xc,yc,'r')
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!