how to obtain the values of a square matrix inside a circular region of image?
조회 수: 1 (최근 30일)
이전 댓글 표시
Suppose we find a circular roi in an image. How to obtain the values of a square matrix or square area inside that circle. give that the x and y coordinates of the circle and its radius
댓글 수: 4
Walter Roberson
2013년 11월 16일
"Largest" in which sense? The greatest area? If so then in a circle the rectangle with the greatest area is a square.
채택된 답변
Walter Roberson
2013년 11월 16일
d = r/sqrt(2);
xcoords = [x-d x+d x+d x-d x-d];
ycoords = [y-d y-d y+d y+d y-d];
line(xcoords, ycoords)
Now what you need to deal with is the rounding to integer coordinates. Rounding towards the center is the safest way. I would need to think more to figure out if there are circumstances under which it might then be possible to get a slightly larger area by extending one pixel further in one direction.
댓글 수: 4
Walter Roberson
2013년 11월 16일
Extracting pixel values:
YourImage(x-d:x+d, y-d:y+d)
In terms of area, Yes, any maximal square inside the circle would do, up to the effects of area reduction due to round-off of non-integers. Circles have no inherent internal orientation, so a square aligned with the axis will have the same area (to within round-off) as a square at (say) 17.29 degrees relative to the origin.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!