Finding the Center of Broken Vase Slices

2 visualizzazioni (ultimi 30 giorni)
Paz Burstein
Paz Burstein il 31 Ott 2024
Modificato: Matt J il 31 Ott 2024
Hello everyone,
I have some slices from a broken vase and I'm trying to determine the center of each slice. Both the outer and inner edges of the slices should ideally share the same center. Can anyone suggest how I might go about finding this center for each piece?
Thank you!
  2 Commenti
Paz Burstein
Paz Burstein il 31 Ott 2024
The slices may not be perpendicular to the main axis of the vase, which means the radii could be a bit elliptical...
Matt J
Matt J il 31 Ott 2024
Modificato: Matt J il 31 Ott 2024
which means the radii could be a bit elliptical...
They may be elliptical in approximation, assuming the slice is almost perpendicular to the vase axis. However, they can only be perfectly elliptical if the vase has a perfectly conic shape.

Accedi per commentare.

Risposte (2)

Matt J
Matt J il 31 Ott 2024
Modificato: Matt J il 31 Ott 2024
You can use ellipticalFit() from this download,
load Image1
[y,x]=find(bwskel(imfill(bw,'holes')));
efit=ellipticalFit([x,y]')
efit =
ellipticalFit with properties: center: [53.4909 -9.7251] a: 60.9185 b: 58.5444 angle: -70.1423
imshow(bw,[]); hold on
showfit(efit); hold off
h=gcf; h.Position(3:4)=5*h.Position(3:4);

Image Analyst
Image Analyst il 31 Ott 2024
Modificato: Image Analyst il 31 Ott 2024
What I'd do is to call bwboundaries on the binary image to get the coordinates of the perimeter. Do it on the original binary image if you can so you get only one boundary, otherwise use the no holes option in bwboundary so you get only the outer boundary.
Then call ginput(2) to get the user to click on two vertex points. Use sqrt() and min() to find the boundary points with the closest distance to where they clicked. Then extract the boundary between those points. Then use the attached function to fit those coordinates to an ellipse using the FAQ
or fit to a circle using the attached function.
From the AI Chat Playground (link above in the blue banner):
function [a, b, h, k, theta] = fitEllipse(x, y)
% Fit an ellipse to the given (x, y) coordinates
% Returns the parameters: semi-major axis (a), semi-minor axis (b),
% center (h, k), and rotation angle (theta)
% Prepare the data
D = [x.^2, x.*y, y.^2, x, y, ones(size(x))];
S = D' * D; % Scatter matrix
[~, ~, V] = svd(S); % Singular value decomposition
a = V(:, end); % Last column of V gives the ellipse parameters
% Extract parameters
h = -a(4) / (2 * a(1));
k = -a(5) / (2 * a(3));
theta = 0.5 * atan2(a(2), a(1) - a(3));
% Calculate semi-major and semi-minor axes
% Using the formula for ellipse parameters
num = a(1) * a(3) - (a(2)^2) / 4;
a = sqrt(2 * (a(1) * h^2 + a(3) * k^2 + a(6) - a(1) * a(3) / num));
b = sqrt(2 * (a(1) * h^2 + a(3) * k^2 + a(6) - a(1) * a(3) / num));
end

Categorie

Scopri di più su 3-D Scene Control in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by