How can I get start and finish coordinates of a line?

13 次查看(过去 30 天)
HiCan we obtain both start and end point coordinates of the spline which is on the picture I have attached.

采纳的回答

Image Analyst
Image Analyst 2012-9-6
Use bwmorph(). First use the 'Skel' option to get the skeleton of the line, then use the 'endpoints' to get the ends of the curves. You can then use find() if you want to know the (column, row) x,y coordinates of the endpoints.
  3 个评论
Image Analyst
Image Analyst 2012-9-7
"First", "Last"? You didn't mention anything about that originally. If you want endpoints of each line one at a time, then you're either going to have to get binary images of one line at a time (hint: use bwlabel and ismember to get those single-curve images) or you're going to have to ask regionprops for "PixelList' and then use ismember to see which blob those endpoints belong to. Give that a try.
Dinçer
Dinçer 2012-9-7
first of all thank you for your previous help. I still in trouble. I attached another picture which can be more clear. I want to get coordinates of two end points of the spline shown in the picture.My purpose is close this spline by getting this end points. I called first point as a start point and second one as an end point on the picture. I have already get coordinates of the end point by using codes below. But I need to get coordinates of start point. How can I do it. Thank you very much.
The codes for getting coordinates of the end point I wrote is;
BW2 = bwmorph(I2,'skel',inf);
endPoints = bwmorph(BW2, 'endpoints');
imshow(BW2);hold on;
[rows cols] = find(endPoints);
[lowestY indexOfLowestY] = min(rows);
[highestY indexOfHighestY] = max(rows);
sonX = [cols(indexOfLowestY) cols(indexOfHighestY)];
sonY = [lowestY highestY];
plot(sonX , sonY , 'gs');

请先登录,再进行评论。

更多回答(1 个)

Saili Ghavat
Saili Ghavat 2016-4-18
I have plot a line in Matlab. Can I use this plot to find the end co-ordinates of the line, or do I have to just use an image?

标签

Community Treasure Hunt

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

Start Hunting!

Translated by