Hello, I wish to draw concentric circles on an image. The radius of each circle is known. The circles are to be plot on the specific position of picture whereby every circle has the same centre. How may i able to do it? The following syntax below is used to generate the concentric circles. I wish to do that on an image. Plus, the circles should be drawn on image with right scalling. Thank you.
%Syntax for concentric circles
theta = [-pi:pi/36:pi];
hold on;
for r=[5,10,15]
plot(r * cos(theta), r * sin(theta))
end

 採用された回答

KSSV
KSSV 2021 年 6 月 9 日

2 投票

I = imread('peppers.png') ;
[m,n,p] = size(I) ;
C = round([n m]/2) ; % center of circle
th = linspace(0,2*pi) ;
imshow(I)
hold on
% draw concentric circle
for r = 5:5:50
x = C(1)+r*cos(th) ;
y = C(2)+r*sin(th) ;
plot(x,y)
end

6 件のコメント

HAINGKHARRAN GUNASEKARAN
HAINGKHARRAN GUNASEKARAN 2021 年 6 月 9 日
Thank you so much. It did work, but if I want to have the centre at different position, is it possible? How may i get the coordinates of different position in the picture (like if I click on the certain position, it will be the centre of the circle) or get the coordinates values directly via any method. Thank you.
KSSV
KSSV 2021 年 6 月 9 日
Read about ginput. getpts to get the points by mouse click.
HAINGKHARRAN GUNASEKARAN
HAINGKHARRAN GUNASEKARAN 2021 年 6 月 9 日
Alright, thanks again.
KSSV
KSSV 2021 年 6 月 9 日
Thanks is accepting and voting the answer... 😄
Image Analyst
Image Analyst 2021 年 6 月 9 日
Like
for radius = 5 : 5 : 50
message = sprintf('Click where you want the center to be');
uiwait(helpdlg(message));
[xCenter, yCenter] = ginput(1);
x = radius * cos(th) + xCenter;
y = radius * sin(th) + yCenter;
plot(x, y, '-');
end
HAINGKHARRAN GUNASEKARAN
HAINGKHARRAN GUNASEKARAN 2021 年 6 月 10 日
Nice, this one worked,,,Thankss

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by