Image Segmentation Part 2 Chromaticity Segmentation

Abel Joshua Cruzada
4 min readJan 28, 2021

In my last blog Image Segmentation Part 1 Thresholding, Otsu and HSV color space , I have discussed segmenting objects of interest in an image using Otsu’s method and HSV color space. However, both methods have their limitations. It may be challenging to use Otsu’s method to segment multiple objects of interest and objects consisting of colors that are not primary colors of light (RGB). In comparison, the HSV color space method can handle Otsu’s method’s limitations. However, it has limitations in segmenting objects with the same HSV value range or an obscure color image. This blog will discuss image segmentation using RG Chromaticity, which solves both methods’ limits.

Chromaticity Segmentation

Chromaticity Segmentation relies on the RG Chromaticity space, a 2-D representation of the color that removes information regarding the intensity value. The equation of the RG color space is shown below.

Fig 1. RG color space equation

In plotting the RG color space, we only need to compute the R and G colors since we can derive the B color using the R and G values. Different colors can be seen in the RG color space, such as a pure red color, R=1, G=0, and B=0, and the color white, which has an R=0.33, G=0.33, and B=0.33.

Let us try to segment the bean bag image from our last blog using Chromaticity Segmentation.

Fig 3. Multiple bean bags

After computing the RG values of the R and G channel, we can plot the RG values to see what colors are in the image.

Fig 4. RG color space of the multiple bean bag image

What if we try to segment the green bean bag in the image? We first need to find a reference patch and take the RG chromaticity of the reference image. We can see what the RG values and the 2D histogram of the patch in the RG color space are from the figure below.

Fig 5. RG color space of the Reference Patch

We can either use Parametric or Non-Parametric segmentation to segment the green bean bag using the reference patch’s RG values. For this example, we are going to use Parametric segmentation. Parametric segmentation requires to fit the reference patch to a gaussian distribution, dictating which pixel belongs to the color of interest. To fit the reference patch to a gaussian distribution, we first need to calculate the patch’s RG values’ mean and standard deviation.

Fig 6. RG mask using Parametric Segmentation (Green patch)

After fitting the reference patch’s R and G values to a gaussian distribution, we can see from the figure above what pixels in the image belong to the R and G chromaticity space. However, since we are considering the probabilities independently, the R and G mask also includes the blue and yellow bean bag. To capture only the reference patch’s color of interest, we can multiply both the R and G mask.

Now, let us try to segment only the orange bean bag. Like in the green bean bag example, we find a reference patch for the orange bean bag. We need to repeat the steps as we did for the green bean bag, and voila, we have isolated the orange bean bag as shown in the figure below.

Fig 7. RG mask using Parametric Segmentation (Orange patch)

Chromaticity segmentation is a powerful tool to segment objects with obscure colors. It is an improvement than using Otsu’s method and HSV color space, where it successfully omits unintended objects with the same HSV color range. We must be careful in selecting our reference patch since a single object can have a wide range of color space.

Originally published at https://abeljoshuacruzada.wixsite.com on January 28, 2021.

--

--

Abel Joshua Cruzada

An aspiring Data Science leader who aims to empower society through data.