How to plot a circle on top of my plotted image

31 ビュー (過去 30 日間)
Ruben Alfaro
Ruben Alfaro 2014 年 5 月 9 日
回答済み: Hugo Diaz 2022 年 2 月 5 日
I have an image plotted and I wanted to plot a circle on top of it with the same centroid of the image.
I want the radius to be 500 and I want it done with a red color, of somebody could help me with this.
thank you very much

回答 (4 件)

lvn
lvn 2014 年 5 月 9 日

Ruben Alfaro
Ruben Alfaro 2014 年 5 月 9 日
Thank you,
But it doesnt seem to work for me, maybe im doing something wrong. can somebody help me figure it out or recommend another way of doing this?
  1 件のコメント
Roberto
Roberto 2014 年 5 月 9 日
post the error you're having, or explain why it doesn't work for you?

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


Image Analyst
Image Analyst 2014 年 5 月 9 日
Try this:
grayImage = imread('concordorthophoto.png');
imshow(grayImage);
axis on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
[rows, columns, numberOfColorChannels] = size(grayImage);
hold on; % Don't let plot blow away the image.
xCenter = columns / 2;
yCenter = rows / 2;
theta = 0 : 0.01 : 2*pi;
radius = 500;
x = radius * cos(theta) + xCenter;
y = radius * sin(theta) + yCenter;
plot(x, y, 'r-', 'LineWidth', 3);
grid on;

Hugo Diaz
Hugo Diaz 2022 年 2 月 5 日
%The trick is to do it 3D, and a 2D plot is like a view from above.
% your 2D plot. If your function f(x,y) < m, then
hold on
r = 1;
teta = -pi:0.01:pi;
x = r * cos(teta);
y = r * sin(teta);
plot3(x, y, m * ones(1, numel(x)), 'Color','k')
hold off

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by