How to find coordinates of two corner points in an image without using ginput?
1 回表示 (過去 30 日間)
古いコメントを表示
I have two corner points (I marked them in red so you can see it) in black and white image. I want to find coordinates of the points automatically without using 'ginput'.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146353/image.jpeg)
I used the 'bwlabel' and 'regionprops' functions to crop an original image to find my region of interest (ROI).
im = imread('LA_shape1.jpg');
LA = im2bw(im, graythresh(im));
[Clab num] = bwlabel(LA);
props = regionprops(Clab);
LABox = imcrop(LA,[props.BoundingBox]);
figure; imshow(LABox);
Here is the result after cropping:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146354/image.jpeg)
Is there any one who can kindly help me to find the coordinates of two corner points without using ginput? Thanks so much!
0 件のコメント
採用された回答
Image Analyst
2014 年 12 月 7 日
No need to crop, label, call regionprops. Why bother if all you want are the endpoints? Simply use bwmorph()
skelImage = bwmorph(binaryImage, 'skel', inf);
endPoints = bwmorph(skelImage, 'Endpoints');
[rows, columns] = find(endPoints);
3 件のコメント
Image Analyst
2014 年 12 月 7 日
It looks like there are actually 2 endpoints per endpoint. That's because when you skeletonize a rectangle, you get s branch going into each corner. Zoom in and you'll see what I mean. I think it would be fine to just average the x and y points to get one point that is halfway in between the two points.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!