How to visualize MajorAxisLength and MinorAxisLength on images?

조회 수: 5 (최근 30일)
Nut
Nut 2016년 7월 12일
댓글: Image Analyst 2018년 1월 15일
Hi,
I would like to replicate something similar to that shown in the explanation of "Orientation" property of the "regionprops" function, as viewable here:
I would plot the red ellipse and the blue lines representing the axes, over my images (both binary and grayscale). I found this example:
but I can't understand how complete the code to plot the blue lines. Could anyone help me, please?
Thanks for your answers.

채택된 답변

Image Analyst
Image Analyst 2016년 7월 12일
Get the two endpoints of the line, then call plot. For example x1 = xCentroid + (majorAxisLength/2) * cosd(orientation). Same for y1, x2,and y2. It's just simple trigonometry. Then call plot([x1,x2], [y1,y2], 'r-').
  댓글 수: 4
hu
hu 2018년 1월 14일
Is it possible to modify the code so I can see how to run it on image contain several objects (like rice.png)?
Thanks a lot.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by