Finding the Center of Broken Vase Slices

37 次查看(过去 30 天)
Paz Burstein
Paz Burstein 2024-10-31,11:13
编辑: Matt J 2024-10-31,20:47
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 个评论
Paz Burstein
Paz Burstein 2024-10-31,11:16
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 2024-10-31,20:46
编辑:Matt J 2024-10-31,20:47
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.

请先登录,再进行评论。

回答(2 个)

Matt J
Matt J 2024-10-31,20:34
编辑:Matt J 2024-10-31,20:34
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 2024-10-31,14:50
编辑:Image Analyst 2024-10-31,18:03
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

类别

Help CenterFile Exchange 中查找有关 3-D Scene Control 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by