How to find coordinates from an image?
Afficher commentaires plus anciens

I have several images like above from a survey. I need to find the coordinates of the laser ring from each image and plot them as 3D image.
I tried to binarize the image and used bwskel make smoother (i.e. 1 pixel laser circle for coordinates) but the skeleton image is not as smooth as I expected. Could anyone please help me? I appreciate any help.
Thank you very much.
Réponses (1)
Image Analyst
le 5 Jan 2021
0 votes
You could use sgolayfilt() with a 2 or 3rd order polynomial to identify outliers and replace them. Or maybe just use filloutliers().
5 commentaires
Amit Pokharel
le 6 Jan 2021
Image Analyst
le 6 Jan 2021
If you know for a fact that the path is a circle, then you could fit the coordinates to a circle using the FAQ:
function [xc,yc,R,a] = circfit(x,y)
%CIRCFIT Fits a circle in x,y plane
%
% [XC, YC, R, A] = CIRCFIT(X,Y)
% Result is center point (yc,xc) and radius R. A is an optional
% output describing the circle's equation:
%
% x^2+y^2+a(1)*x+a(2)*y+a(3)=0
% by Bucher izhak 25/oct/1991
n=length(x); xx=x.*x; yy=y.*y; xy=x.*y;
A=[sum(x) sum(y) n;sum(xy) sum(yy) sum(y);sum(xx) sum(xy) sum(x)];
B=[-sum(xx+yy) ; -sum(xx.*y+yy.*y) ; -sum(xx.*x+xy.*y)];
a=A\B;
xc = -.5*a(1);
yc = -.5*a(2);
R = sqrt((a(1)^2+a(2)^2)/4-a(3));
Also, which of the many rings do you want? You might threshold and use bwareafilt() to take just the largest region. You could just fit all the x and y from find() -- no need to skeletonize since it's a fit.
binaryImage = bwareafilt(binaryImage, 1); % Take ring with largest area.
[y, x] = find(binaryImage); % Of just one of the rings. Note: it's y,x NOT x,y
[xc, yc, R, a] = circfit(x,y)
viscircles([xc, yc], R);
Amit Pokharel
le 6 Jan 2021
Image Analyst
le 6 Jan 2021
Amit Pokharel
le 6 Jan 2021
Catégories
En savoir plus sur Polar Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!