8: Blob Detection and Connected Components
Blob Detection, as the name suggests, allows us to detect objects of interests (blobs) in our image. Blobs are defined as bright objects in a dark background or vice versa. We will be using three methods to automatically detect our blobs:
- Laplacian of Gaussian (LoG) — takes the laplacian of a gaussian smoothed image
- Difference of Gaussian (DoG) — takes the difference of two gaussian smoothed image
- Determinant of Hessian (DoH) — takes maximum in the matrix of the determinant of Hessian
Let us consider this gray scale -> binarized image of a bunch of candies on a table.
Applying the 3 different techniques on an image of this size takes a decent amount of time, with each one having its pros and cons compared to the other method. This method however, is unable to properly distinguish each individual candy into its own blob. The binary image shows that there are gaps present in the center of each candy. In fact no candy has a single clear presence. This calls for the morphological operations and regionprops that will be discussed in a while.
One usage of this method can be seen in counting the number of grapes in this image. Here the mask is made of bigger filled blobs composed of smaller blobs or the individual grapes.
A detailed explanation on how the blobs detect is available in the official reference provided.
Going back to the candies image, applying morphological operations somewhat filled the individual candies. The individual candies that are not connected to each other can now be labelled. If the edges of 2 or more candies are touching, the function considers them as a single large candy. The regionprop function allows this labelled image to be further filtered as well. A range of details for each labelled sub-image such as the area, bounding box, eccentricity, and many more are available to extract.