No BSD License  

Highlights from
Draw a circle in a matrix / image

3.45455

3.5 | 11 ratings Rate this file 95 Downloads (last 30 days) File Size: 824 Bytes File ID: #14331
image thumbnail

Draw a circle in a matrix / image

by Peter Bone

 

19 Mar 2007 (Updated 19 Mar 2007)

Draw a circle in a 2D matrix using the integer midpoint circle algorithm

| Watch this File

File Information
Description

This is a good example of the integer midpoint circle algorithm. No pixels are missed or repeated.

MATLAB release MATLAB 7.3 (R2006b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (16)
19 Mar 2007 dave martin

Boring.

19 Mar 2007 Urs (us) Schwarz

the fact that the reviewer below finds the submission boring is not substantial and certainly does not warrant a poor rating by itself. please, be more considerate.
to the author: the function could be spruced up a bit, eg, an x/y-offset option
us

01 Apr 2007 John Jorsett

Just what I was looking for and not "boring" at all.

05 May 2007 Huan Tan

agreed! every little tool like this can find its place. very helpful, just what i was looking for

14 Sep 2007 Mustafa Sami  
01 Jan 2008 sorry sorry

i hope if one till me how to use it, can one tell us i, value stand for what....

29 Feb 2008 Tom Canty

Comments in your code isnt just for coding class, it helps others understand your code

22 Mar 2008 Ellen Blinka

When I ran the code, there were some skipped pixels in the drawn circle.

29 Jun 2008 Sheila Geva

Hi,
I need to draw circles in each cell in an intensity matrix that I'm printing. How do I use your code to do so?
Also, I don't understand the parameters that need to be put in the function. Please explain?

10 Jul 2008 John Doe

Excellent, clean implementation. This is the first of over a dozen submissions I've seen that actually uses this algorithm (and they all should). Very nice. Commenting your code would be a nice touch, however...

13 Aug 2008 Andrew Harward

It is simple to modify this function to allow circles of both odd & even size (currently the algorithm cannot produce even sized e.g. 8x8 circles). Maybe I'll post up a modified version if that's OK with you?

15 Aug 2009 Matthew

Can someone fill me in as to how this code works. Also, can it be altered to make an annulus as opposed to just a circle?

06 Apr 2011 Nor Muzakkir

got it working.

i = the pixel value for coordinate (1,1).
radius = radius of the circle.
xc and yc = center coordinate of the circle.
value = the pixel value for the circle.

extra note: the value for xc and yc must be larger than radius.

thanks author, i've been searching for this kind of function.

20 Jul 2011 chitra s

what value i have to give for the parameter 'value'?

03 Sep 2011 William Lau Kai Wei

this is a coding to draw a circle.
i using the same code but i looping it with reduce the radius.

let say, my radius is 7, I try looping it by draw radius with 7, and then 6, and then 5 and so on until it become 0. It really fill in a lot of space but the problem is still got some space is empty.

My problem now is I want to fill in all the area inside the circle. So, any idea to solve this problem? Thank you

29 Oct 2011 Ibtissem Labed

i

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
draw Peter Bone 22 Oct 2008 09:05:04
circle Peter Bone 22 Oct 2008 09:05:04
2d Peter Bone 22 Oct 2008 09:05:04
utilities Peter Bone 22 Oct 2008 09:05:04
image Peter Bone 22 Oct 2008 09:05:04
matrix Peter Bone 22 Oct 2008 09:05:04
2d db3809 Bukovec 09 Mar 2009 12:53:01
draw Kumar Kumar 29 Aug 2009 06:58:46
matrix Gregory Carnegie 12 Mar 2010 14:17:59
image Laurent 27 Jan 2011 13:27:16
matrix Laurent 27 Jan 2011 13:27:20
draw kishore aluri 29 Jul 2011 10:09:07
2d Mohammad Reza 26 Oct 2011 13:08:22
circle Ibtissem Labed 29 Oct 2011 10:45:38

Contact us at files@mathworks.com