Opencv SimpleBlobDetector filterByInertia mean?

I don’t understand what filterByInertia means ... and I don’t understand the documentation, a small description:

The ratio of minimum inertia to maximum inertia. Extracted drops will have this ratio between minInertiaRatio (inclusive) and maxInertiaRatio (exception).

+8
opencv
source share
3 answers

I was also interested in this from time to time; OpenCV documentation is not very useful when it comes to blob detection.

Based on descriptions of other blob analyzers , the inertia of a blob is the "inertial resistance of the blob to rotate around its major axes." It depends on how the blob mass (I suppose, in this case the area) is distributed throughout the droplet shape.

There are many mats involved, most of which I don’t remember how to do, but the result at the bottom of this page about the properties of binary images sums up quite well (blob detection is done by converting the input image into a series of binary images):

Attitude I_min / I_max gives us some idea of ​​how rounded the object is. This ratio will be 0 for the line and 1 for the circle.

So basically by setting minInertiaRatio and maxInertiaRatio , you can filter the drops depending on how elongated they are. A ratio of inertia of 0 will produce elongated drops (closer to the lines), and a ratio of inertia of 1 will give drops, where the area is more concentrated towards the center (closer to the circles).

+9
source share

Blob characteristics . The above image pretty much explains what the various filter options do. SimpleBlobDetector is happiest when it sees a circular frame, and various filters filter different children from circular deviations.

Inertia measures the ratio of the minor and major axes of the blob.

The figure also shows the difference between roundness and inertia. I copied this figure from the Blob Tutorial at LearnOpenCV.com

+7
source share

Here's the physical intuition:

If you cut drops on a piece of the map, you can find its center of gravity, and then attach the axis to it, crossing this point (the axis will be parallel to the map), and then twist it and measure the moment of inertia. Depending on the shape, you can get different values ​​depending on how you place the axis. For an ellipse, you get the smallest value when the axis is attached along the long (main) axis and the largest when the axis is placed along the short axis (so that most of the map is far from the axis). Of course, inertia is always the same for a circle.

If there are different values, there will always be inertia "max" with some orientation, and "min" with an axis located 90 degrees from "max". The inertia ratio is simply the ratio between these interactions, min / max.

For shapes that are not ellipses, the metric tells you whether the overall shape is roughly elongated or roughly the same size in all directions; without caring, in particular, about an uneven border or cuts and concavity (on which roundness and convexity are visible).

Mathematically, he does something like this:

  • Consider the set of points inside the blob as a collection of (x, y) samples
  • Find the average of them and the covariance matrix x vs. y
  • Find two eigenvalues ​​of the covariance matrix (which coincide with its singular values ​​due to the nature of this matrix)
  • The inertia ratio is the ratio between these two values, the smallest / largest.
+2
source share

All Articles