| MIL 10 User Guide
| Customize Help

The area and perimeter



See also
Availability
Not available in MIL-Lite

Available in MIL

Each pixel in your image represents a real width and height (for example, in millimeters). However, MblobCalculate() performs calculations and measurements (that represent a distance or area) in raw (uncalibrated) pixel units. By default, MblobCalculate() assumes that the width and height of the pixels are the same (that is, the pixel aspect ratio (width/height) equals 1.0); therefore, each pixel (P) is represented as follows:

A pixel ratio of 1.0 implies that the area (M_AREA) of a single pixel blob is equal to 1 and the perimeter (M_PERIMETER) is equal to 4. When calculating the area and perimeter of a larger blob, the area would then equal the number of pixels in the blob (excluding holes), and the perimeter would equal the total number of pixel sides along the blob edges (including the edges of holes). Note, an allowance is made for the staircase effect that occurs in a digital image when representing diagonals and curves. For example, in the following blob (where F represents foreground pixels), the area is 10 and the perimeter is 14.242.

When two diagonals intersect, as in the image below, the perimeter is calculated as the sum of the straight edges and of the diagonals (calculated as described above) with a correction of -1 for each intersection of diagonals. For example, in the following blob, the area is 11 and the perimeter is 17.656.

If what is of more interest is the smallest area or smallest perimeter of the rectangular region that a blob occupies (bounding box), you can select for calculation M_MIN_AREA_BOX and M_MIN_PERIMETER_BOX, respectively. For more information on bounding boxes, see the Finding the blob location and its bounding box section later in this chapter.

You can also calculate an accurate representation, or an approximation, of the convex perimeter of the blobs using M_CONVEX_HULL_PERIMETER or M_CONVEX_PERIMETER respectively. The convex perimeter is the perimeter of the convex hull (see below).

The approximation of the convex perimeter (M_CONVEX_PERIMETER) is derived by taking the diameter of the blob (Feret diameter) at different angles. You can adjust the number of Feret diameters used with the MblobControl() function. The greater the number of Feret diameters used, the more accurate the approximation.

Note that the Feret diameters are calculated using a method which treats pixels as being round with a diameter of 1 instead of being square (see the Dimensions section later in this chapter). This can lead to results not matching the expected result. For example, when dealing with a single pixel blob, the result approaches 3.1416 (that is, Pi) which is the perimeter of a circle with a diameter of 1.

When the pixel aspect ratio has been set to anything other than 1.0, using MblobControl(), the aspect ratio is applied to the pixel width during calculations. Each pixel is now represented as:

This affects all calculated features as if you had actually stretched the image (from the top-left corner in the x-direction only), by a factor equal to the pixel aspect ratio. We can no longer say that results are in "pixel" units. In fact, results are really in units of "pixel height" since the height is not affected by the aspect ratio.