MATLAB Answers

How to plot a circle on top of my plotted image

조회 수: 104(최근 30일)
Ruben Alfaro
Ruben Alfaro 2014년 5월 9일
답변: Image Analyst 2014년 5월 9일
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


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 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');
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;

Community Treasure Hunt

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

Start Hunting!

Translated by