Finding the Center of Broken Vase Slices

조회 수: 2 (최근 30일)
Paz Burstein
Paz Burstein 2024년 10월 31일
편집: Matt J 2024년 10월 31일
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일
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일
편집: Matt J 2024년 10월 31일
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일
편집: Matt J 2024년 10월 31일
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일
편집: Image Analyst 2024년 10월 31일
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