フィルターのクリア

Pixel position of circle on image

5 ビュー (過去 30 日間)
sangeeta
sangeeta 2013 年 3 月 21 日
How to find and store in list(x1y1, x2y2, x3y3, ...... xnyn)all the pixel positions that a circle would cross, on an image, given only the center point (x,y) and radius of circle. There is no actual circle.

回答 (2 件)

Sven
Sven 2013 年 3 月 21 日
編集済み: Sven 2013 年 3 月 21 日
Sangeeta, does this answer your question:
center = [25 30]; %XY location of circle center
radius = 15;
matSize = 50;
[X,Y] = meshgrid(1:matSize,1:matSize);
distFromCenter = sqrt((X-center(1)).^2 + (Y-center(2)).^2);
onPixels = abs(distFromCenter-radius) < 0.5;
[yPx,xPx] = find(onPixels); % THIS is your answer!
figure, plot(xPx,yPx,'g.', center(1),center(2),'ro')
rectangle('Position',[center-radius [2 2]*radius], 'Curvature',[1 1])
axis image
  1 件のコメント
sangeeta
sangeeta 2013 年 4 月 16 日
Thanks Sven for the code, but seems little difficult to grasp for me. I managed to find out pixels using
if true
r = 60;
theta = 0 : (2 * pi / 10000) : (2 * pi);
pline_x = r * cos(theta) + centx;
pline_y = r * sin(theta) + centy;
end

サインインしてコメントする。


Image Analyst
Image Analyst 2013 年 5 月 19 日
The answer to this is given in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F
xCenter = 12;
yCenter = 10;
theta = 0 : 0.01 : 2*pi;
radius = 5;
x = radius * cos(theta) + xCenter;
y = radius * sin(theta) + yCenter;
plot(x, y);
axis square;
xlim([0 20]);
ylim([0 20]);
grid on;

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by