Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

area of circle in pixels

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?

0 Kudos
Message 1 of 3
(5,892 Views)

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)

Randall Pursley
0 Kudos
Message 2 of 3
(5,878 Views)

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

Bruce Ammons
Ammons Engineering
0 Kudos
Message 3 of 3
(5,871 Views)