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:

  1. Laplacian of Gaussian (LoG) — takes the laplacian of a gaussian smoothed image
  2. Difference of Gaussian (DoG) — takes the difference of two gaussian smoothed image
  3. Determinant of Hessian (DoH) — takes maximum in the matrix of the determinant of Hessian
Gray-scale and binary image

Let us consider this gray scale -> binarized image of a bunch of candies on a table.

Different Blob Algorithms

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.

Counting Blobs

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.

Labelling non-connected blobs

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.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nisarg Nigam

Nisarg Nigam

MS Data Science student at Asian Institute of Management