The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

- Help others & share knowledge
- Earn cash & points
- Learn & ask questions

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

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