Prev Tutorial: Contour Features
Next Tutorial: Contours : More Functions
Goal
- Here we will learn to extract some frequently used properties of objects like Solidity, Equivalent Diameter, Mask image, Mean Intensity etc.
1. Aspect Ratio
It is the ratio of width to height of bounding rect of the object.
\[Aspect \; Ratio = \frac{Width}{Height}\]
2. Extent
Extent is the ratio of contour area to bounding rectangle area.
\[Extent = \frac{Object \; Area}{Bounding \; Rectangle \; Area}\]
3. Solidity
Solidity is the ratio of contour area to its convex hull area.
\[Solidity = \frac{Contour \; Area}{Convex \; Hull \; Area}\]
4. Equivalent Diameter
Equivalent Diameter is the diameter of the circle whose area is same as the contour area.
\[Equivalent \; Diameter = \sqrt{\frac{4 \times Contour \; Area}{\pi}}\]
5. Orientation
Orientation is the angle at which object is directed. Following method also gives the Major Axis and Minor Axis lengths.
6. Mask and Pixel Points
In some cases, we may need all the points which comprises that object.
We use the function: cv.transpose (src, dst)
- Parameters
-
src input array. dst output array of the same type as src.
7. Maximum Value, Minimum Value and their locations
We use the function: cv.minMaxLoc(src, mask)
- Parameters
-
src input single-channel array. mask optional mask used to select a sub-array.
8. Mean Color or Mean Intensity
Here, we can find the average color of an object. Or it can be average intensity of the object in grayscale mode. We again use the same mask to do it.
We use the function: cv.mean (src, mask)
- Parameters
-
src input array that should have from 1 to 4 channels so that the result can be stored in Scalar. mask optional operation mask.