Page 1 of 1

draw circle radius

Posted: 2017-12-16T15:46:10-07:00
by bonobo2000
I use

Code: Select all

convert -size 8x8 xc: -draw "translate 0,0 circle 0,0 3,0" ./bla.png
I would expect a circle with a radius of 3 pixels. However, I am getting is a circle with 4 pixels radius. While this might or not be a bug, it certainly doesn't fit the second example shown in the documentation in http://www.imagemagick.org/Usage/draw/#circles .
cheers

Re: draw circle radius

Posted: 2017-12-16T15:52:17-07:00
by fmw42
I think that the actual radius value is added to the center pixel to get to the circle perimeter.

0 1 2 3

So from 0 you add 3 more to get to the radius of 3, which is the 4th pixel.

Or perhaps better you can think of it as from 0 to 1 is distance 1, 1 to 2 is distance 1 and 2 to 3 is distance 1. So adding up all the distances your get a total distance of 3. So the distance or change is 3, and starting from 0. So it includes 4 pixels.

I get the same thing as described from above from both commands that follow

Code: Select all

convert -size 8x8 xc:black -fill white -draw "translate 0,0 circle 0,0 3,0" bla.png
convert -size 8x8 xc:black -fill white -draw "circle 0,0 3,0" bla2.png

Re: draw circle radius

Posted: 2017-12-16T16:10:13-07:00
by snibgo
The difficulty is that "radius" (like "diameter" and most other distance) is usually defined as the distance between centres of pixels, not the total distance including the thickness of the pixels at both ends.

The documentation http://www.imagemagick.org/script/comma ... s.php#draw says:
Give the center and any point on the perimeter (boundary).
So your centre is at 0,0 and the circle passes through 0,3. The distance between the centres of these pixels is 3.

Re: draw circle radius

Posted: 2017-12-17T21:58:13-07:00
by snibgo
Here's another way of thinking:

Code: Select all

convert -size 9x9 xc: -draw "circle 4,4 4,7" -scale 500x500 circrad3.png
Image

Simplistically, the radius is 3. But what is the diameter, including the full width or height of the pixels? That diameter is 7. So that radius (from the dead centre, to any extreme) is 3.5.

So it really depends on how we define "radius" (and "diameter").

Re: draw circle radius

Posted: 2017-12-17T22:10:55-07:00
by fmw42
Another way to look at it is that from the center of the center pixel to the center of the far right pixel is exactly 3. So if you consider the "circle" perimeter to have one pixel thickness, then the distance from the very center of the circle to middle of the perimeter pixel is 3.