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/wi

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
```

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

Hashing Algorithm | 5 | 29 | |

Round up to 100% in .NET | 10 | 43 | |

XML & .net | 5 | 18 | |

Error in LINQ - New transaction is not allowed because there are other threads running in the session | 3 | 10 |

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

Connect with top rated Experts

**15** Experts available now in Live!