04-20-2011 08:48 AM
I found a simple problem of calculating area of a circle in pixel values. for example, for radius=5 pixels,the area is 97 pixels (not 78.54 pixels). Is there any place where i can find the conversion or formula that can be used to calculate the area in pixels?
04-21-2011 09:16 AM
What criteria are you using to determine whether a pixel is considered part of the interior of the circle? I would use the 50% rule. You would be essentially finding the area of the bounding rectangle and subtracting pixels from the corners to approximate a circle. Here is a table, but I can't really see a good pattern.
Radius Area Square Area Circle Difference
1 4 4 0 (0)
2 16 14 4 (1)
3 36 32 4 (1)
4 64 52 12 (3)
5 100 80 20 (5)
6 144 112 32 (8)
7 196 156 40 (10)
8 256 208 48 (12)
9 324 256 68 (17)
10 400 316 84 (21)
04-21-2011 11:18 AM
Perhaps add 0.5 to the radius before plugging it into PI R^2. The radius when drawing is probably to the center of the pixel, while the radius while calculating area needs to include out to the edge of the pixel.
When I plug in 5.5 for the radius, I get 95 pixels, which is very close to the 97 you measured. You can test it out on a few different sized circles. Larger circles will probably match best. Any radius smaller than a few pixels will produce a circle so blocky that the area calculation will be off no matter what.
You could also back calculate the radius from the measured area for a few different circles and see what it looks like. Once again, larger circles would be the most useful.
Bruce