Finding center of a line
이전 댓글 표시
Hi i need to find the center of a line.A robot needs to foolow this line in real time but my problem is how to find the center of a line.I used bwmorph(image,'thin',inf); and i get the that my thick line thins to a line with 1 pixel size.
so now the only thing that i need is to calculate the distance between the center of my image (blue +) and the line so i could say to my robot move to left so that the center of the line is equal to the image center. .
채택된 답변
추가 답변 (2개)
Image Analyst
2012년 1월 30일
0 개 추천
How about using the Pythagorean Theorem? Look up MATLAB's hypot() function.
댓글 수: 3
samir
2012년 1월 30일
Image Analyst
2012년 1월 30일
You're right, if the "line" is not straight. You can't just find the centroid because the centroid may not line on or in the line. You could try bwboundaries() and play around with what that returns.
samir
2012년 1월 31일
Kevin Moerman
2012년 1월 31일
0 개 추천
If its a straight line then you could simply take the mean of your line coordinates (or even centre of gravity of the image object).
If the line is curved then sum up line segments to get total curve length (calculate point-to-point distances and use cumsum for instance), and then solve for (e.g. interpolate) what coordinate describes half of the curve length.
카테고리
도움말 센터 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!