Object labeling

After segmentation of image, we will need to separate each object on image from others. Just to make it clear, you should at least use thresholding on the image, in case there is noise which we do not want to classify as objects.

After separating actual objects from background (we can use binary image as well), we need to label certain objects in image. In this example we will use objects that are continuous in image space, and they won’t contain separated pixels.

Indexed image example grid

We can implement this process using a simple flood fill algorithm. In this algorithm, we go through all the pixels and if it belongs to the objects, we label this pixel with chosen constant and recursively flood fill four neighbors with this constant too. As one might expect, we label each object with different constant.

Second part of this practice will be computing the center of the object, and correctly show it into the image. In general form we can use computation of moments of object (this is similar to physic) where we use generalized form:

And the center of the objects is:

I will just note the general formula for computing moments of objects, and it is up to your will if you use them for later image classification or not.

For example m(0,0) can later be used as generalized formula of object area.

Return to top

    Labeled objects

Sollution in LV


Data Value
Source https://en.wikipedia.org/wiki/Connected-component_labeling