How to scan a circle that is drawn over an image object?

조회 수: 2 (최근 30일)
Zara Khan
Zara Khan 2018년 7월 14일
댓글: Zara Khan 2018년 7월 15일
A circle is drawn over a binary image object using plot. After this drawn I again want to scan this circle and want to store its circumference coordinates points to an array. How to do that?
  댓글 수: 4
Walter Roberson
Walter Roberson 2018년 7월 14일
편집: Walter Roberson 2018년 7월 14일
Quantize the coordinates to integers, and take the unique pairs. No drawing required. If you need them in order, you can use boundary() or you can subtract the centroid so that the points circle the centroid, and then convert to polar coordinates, and sort by angle.
Zara Khan
Zara Khan 2018년 7월 14일
편집: Zara Khan 2018년 7월 14일
I have got my unique points and this is forming a straight line . I am not getting any circle. How to resolve this ?

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

채택된 답변

Image Analyst
Image Analyst 2018년 7월 14일
The form or size of the image below doesn't matter. It could be binary (with various irregularly shaped blobs in it), RGB, gray scale, whatever - it just doesn't matter.
Since you already have your (x,y) points of the "circle" (because you plotted them), if they're not already your circumference points (like it's a wiggly circle instead of a perfect circle), then you can fit a circle to what you have to get the "perfect" circle radius and center using the FAQ: https://matlab.wikia.com/wiki/FAQ#How_can_I_fit_a_circle_to_a_set_of_XY_data.3F
Now once you have the perfect circle, you can regenerate the perfect circle coordinates. Call round() on them if you want to quantize them to integer row, column values.
  댓글 수: 6
Image Analyst
Image Analyst 2018년 7월 14일
The just call poly2mask() with your x,y coordinates, and get an image, then just call bwboundaries() on that image. Done. Simple.
Zara Khan
Zara Khan 2018년 7월 15일
Thank you I am done.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by