Plotting points around ellipses using values from regionprops (or obtaining the function of the ellipse)
Mostrar comentarios más antiguos
I have plotted the centroids of an image containing coatings (represented by the almost concentric ellipses) as shown below using values from regionprops:

I want to measure the thickness of the coatings as function of the ellipse angles by plotting points around the ellipses and using the distance formula to get the thickness. However, when I try to plot points on the ellipses based on the MajorAxisLength and MinorAxisLength values, they are completely wrong:

Is there an easier method to measure the coating thickness? A main problem I am having with this method is determining the equation of the ellipses. I am having a difficult time visualizing MajorAxisLength and MinorAxisLength on the image (EDIT: added the Orientation values when using regionprops). I have attached the thresholded image + images used + the bw image.
a= imread('C:\Users\15107\Downloads\SEM Fiber Pictures\ATL Mini 1-C Pristine Transverse_T1_057 (Find Edges) - Cropped.tif'); %open image file
b=im2gray(a); %convert to grayscale/2-D array matrix
bw = b>100; %convert from unit8 to logical
figure,imshow(bw) %show image
axis on
hold on
title('Image with Circles')
stats = regionprops('table',bw,'Centroid','Area','MajorAxisLength','MinorAxisLength','Orientation'); %obtain centroid, area, major and minor axis length, orientation data
newstats = table2array(stats); %convert stats from table to array
Area = stats.Area; %initialize matrix containing area data
statsvector = [];
for i = 1:length(Area)
if newstats(i,1) > 2000 %condition to filter out areas less than 2000
statsvector(i,:) = [newstats(i,2:6);]; %make new matrix containing the rows only containing areas > 2000; the rest of the rows are converted into zeros
end
end
B = statsvector;
B(any(B==0,2),:) = []; % Remove any rows with a zero
X_B = B(:,1); %X coordinates (h)
Y_B = B(:,2); %Y coordinates (k)
plot(X_B,Y_B,'b*')
%%
%Equation of an ellipse w/ horizontal major axis: ((x-h)^2)/a^2 + ((y-k)^2)/b^2 = 1
ellipse_horizontal_minus = []; %h-a
ellipse_horizontal_plus = []; %h+a
ellipse_vertical_minus = []; %k-b
ellipse_vertical_plus = [];%k+b
for i = 1:length(B)
ellipse_horizontal_minus(i) = B(i,1)-(B(i,3)/2);
ellipse_horizontal_plus(i) = B(i,1)+(B(i,3)/2);
ellipse_vertical_minus(i) = B(i,2)-(B(i,4)/2);
ellipse_vertical_plus(i) = B(i,2)+(B(i,4)/2);
if ellipse_horizontal_minus(i) < 0
ellipse_horizontal_minus(i) = B(i,2)-(B(i,4)/2);
end
if ellipse_vertical_minus(i) < 0
ellipse_vertical_minus(i) = B(i,1)-(B(i,3)/2);
end
end
plot(ellipse_horizontal_minus,Y_B,'b*')
plot(ellipse_horizontal_plus,Y_B,'r*')
plot(ellipse_vertical_minus,X_B,'m*')
plot(ellipse_vertical_plus,X_B,'g*')
3 comentarios
Scott Phan
el 28 de Feb. de 2022
Matt J
el 1 de Mzo. de 2022
My suggestion was to put it in a .mat file.
Respuesta aceptada
Más respuestas (2)
You can use bwboundaries() to get the coordinates of the ellipse boundaries.
bwboundaries( imfill(bw,'holes') )
You can then fit the coordinate data with, for example, the ellipticalFit() function from this package:
You can convert the ellipse equation to polar form using the formula from,
Image Analyst
el 1 de Mzo. de 2022
0 votos
See Steve's blog, which fill put ellipses around each detected blob:
Categorías
Más información sobre Log Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
