Solved

Posted on 2010-09-03

I have a graphicspath shape in a picturebox, created from a set of lines and some beizer curves. does anyone know how to find the area of the shape. I know how find the points along any of the sides of the shape, and i know what the bounding rectangle is

thanks for any help

example image

thanks for any help

example image

4 Comments

A special case of Green's theorem when the closed curve C is given by discrete coordinates is often called "Surveyor's Formula" (see under the paragraph "Area and centroid" here: http://en.wikipedia.org/wiki/Polygon)

If you have all vertices for the straight lines and enough points on the curved ones, the sum (area) should be easy to calculate.

Assuming, for ease, that the image is a black and white with just 1 bit, then each pixel is 0 or 1. So, just count the number of pixels equal to 1 and you have the area.

As in CODE 1.

If the pixels are 8 bit deep, then CODE 2 applies.

The same approach is ok for color images.

The area is given in pixels. If you need the area in inches, for example, just calculate the area (as in CODE 1 or 2) and divide it by (N*N), being N the number of pixels by inch of your image.

```
// CODE 1 ---> image 1 bit deep
area = 0
for x=1 to width
for y=1 to height
if pixel(x,y) not zero then area = area + 1
next y
next x
//---------------------------------
// CODE 2 ---> image 8 bit deep (256 levels)
area = 0
for x=1 to width
for y=1 to height
if pixel(x,y) not zero then area = area + pixel(x,y)
next y
next x
area = area/256
```

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Title | # Comments | Views | Activity |
---|---|---|---|

SlingPlayer alternatives | 1 | 35 | |

SQL Login | 17 | 40 | |

Facial recognition to look through the whole database for a person | 3 | 43 | |

C# parent child form | 5 | 19 |

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**13** Experts available now in Live!