How to convert arc circle plot into binary circle?
조회 수: 2 (최근 30일)
이전 댓글 표시
how to change the circumference into binary circle ?
댓글 수: 0
채택된 답변
KSSV
2021년 6월 17일
R = 1;
th = linspace(0,2*pi,1000) ;
x = R*cos(th) ; y = R*sin(th) ;
xi = linspace(-2,2,100) ;
yi = linspace(-2,2,100) ;
[X,Y] = meshgrid(xi,yi) ;
Z = zeros(100) ;
idx = knnsearch([X(:) Y(:)],[x' y']) ;
Z(idx) = 1 ;
imagesc(Z)
댓글 수: 3
Walter Roberson
2021년 6월 19일
Change
th = linspace(0,2*pi,1000) ;
to only have the range of angles that you want the arc to cover.
추가 답변 (1개)
Walter Roberson
2021년 6월 19일
https://matlab.fandom.com/wiki/FAQ#How_do_I_create_an_arc.3F shows how to create an arc.
But for your purpose, instead of using plot(), multiply the coordinates by the resolution you want, and round() them, and then subtract off the minimum x and y . Now you have matrix coordinates.
resolution = 25;
th = linspace(0, 7*pi/9, 500);
r = 5;
xc = 3;
yc = 7;
[x,y] = pol2cart(th, r);
x = x + xc;
y = y + yc;
%the above are data coordinates. Make them into array coordinates.
buffer = 5;
xm = round(x * resolution);
ym = round(y * resolution);
xmin = min(xm);
ymin = min(ym);
xmax = max(xm);
ymax = max(ym);
xmc = xm - xmin + 1 + buffer;
ymc = ym - ymin + 1 + buffer;
arc_image = accumarray([ymc(:), xmc(:)], 1);
imshow(arc_image)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Polar Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!