Clear Filters
Clear Filters

how to draw a circle in an image?

1 view (last 30 days)
ajeet verma
ajeet verma on 1 Mar 2017
Answered: Image Analyst on 1 Mar 2017
i want to draw a circle on an image using this equation x^2+y^2=r
  1 Comment
Jan
Jan on 1 Mar 2017
Edited: Jan on 1 Mar 2017
According to this formula, the circle is a line with an infinitesimal width, such that it is invisible on the screen. Do you want to draw a disc? Do you mean r^2?

Sign in to comment.

Accepted Answer

Jan
Jan on 1 Mar 2017
img = rand(100, 100, 3) * 0.2; % Test data
value = bsxfun(@plus, ((1:100) - 50) .^ 2, ((1:100).' - 50) .^ 2);
r = 30;
mask = value < (r + 1)^2 & value > (r - 1)^2;
mask3 = cat(3, mask, mask, mask);
img(mask3) = 1.0;
image(img);

More Answers (1)

Image Analyst
Image Analyst on 1 Mar 2017

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!