필터 지우기
필터 지우기

Obtaining coordinate values within circular ROI

조회 수: 4 (최근 30일)
Brian
Brian 2016년 1월 21일
댓글: Michael Werthmann 2019년 2월 28일
Hello all,
I have a function that receives xlist (vector of row coordinates) and ylist (vector of column coordinates) as inputs. I would like create another function that allows users to just select a starting coordinate (x, y) and it will capture all coordinates within a circular region of radius r (predefined) in the format of xlist and ylist.
My image is always 512*512 (grayscale CT). How do I do this?
Thank you so much!
  댓글 수: 1
Michael Werthmann
Michael Werthmann 2019년 2월 28일
Hello Brian,
I have a similar problem. Die you manage to solve yours?
Regards
Michael

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

답변 (1개)

KSSV
KSSV 2019년 2월 28일
Check this demo example:
I = imread('cameraman.tif') ;
[ny,nx] = size(I) ;
C = input('Enter center of circle C(x,y), should be less then 256:','s') ;
R = input('Enter Radius of circle:','s') ;
%
C = str2num(C) ;
R = str2num(R) ;
%
th = linspace(0,2*pi) ;
xc = C(1)+R*cos(th) ;
yc = C(2)+R*sin(th) ;
[X,Y] = meshgrid(1:nx,1:ny) ;
idx = inpolygon(X(:),Y(:),xc,yc) ;
I(~idx) = 255 ;
imshow(I)

Community Treasure Hunt

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

Start Hunting!

Translated by