Computing the Number of Groups for Color Image Segmentation Using Competitive Neural Networks and Fuzzy C-Means

. Fuzzy C-means (FCM) is one of the most often techniques employed for color image segmentation; the drawback with this technique is the number of clusters the data, pixels ’ colors, is grouped must be de ﬁ ned a priori. In this paper we present an approach to compute the number of clusters automatically. A competitive neural network (CNN) and a self-organizing map (SOM) are trained with chromaticity samples of different colors; the neural networks process each pixel of the image to segment, where the activation occurrences of each neuron are collected in a histogram. The number of clusters is set by computing the number of the most activated neurons. The number of clusters is adjusted by comparing the similitude of colors. We show successful segmentation results obtained using images of the Berkeley segmentation database by training only one time the CNN and SOM, using only chromaticity data.


Introduction
Image segmentation by color features has been employed for different purposes; for instance, analysis of rocks [1], food [2,3], medicine [4,5], among others [6,7]. The algorithms of related works are based on FCM [8][9][10]; the FCM require a priori knowledge of the number of clusters the image should be segmented.
In related works the number of clusters is defined by the user [11,12]; in other ones the number is set by computing the "dominant" colors of the image [10,[13][14][15]. Basically, the techniques introduced in [13,14] work as follows: a SOM is trained with the colors of the image, represented in the RGB space, and then the image is processed by the SOM where in a histogram the activation occurrences of each neuron are collected. Finally the number of clusters is obtained by computing the number of peaks of the histogram.
Using this technique involves the SOM is trained every time a new image is given, which it may be time consuming. On the other hand, most of the works employ the RGB space to represent colors but this space is light sensitive, i.e., two colors with the same chromaticity but with different intensities can be grouped in different clusters [16]. Despite other works employ other color spaces, where the chromaticity is separated from the intensity, the intensity data is also used to process the images, but similar effects are obtained as if the RGB space is employed [10,11,14,17].
Our proposal consist on computing the number of dominant colors by processing the chromaticity of colors, emulating the way the humans perceives colors; that is, humans recognize colors mainly by the chromaticity then by the intensity [16,18]. Also, humans are capable to recognize the different regions within an image by just identifying the chromaticity features of such sections without using the intensity data of the colors; it is important to mention humans employ the knowledge acquired previously to recognize colors, i.e., they do not need to learn to recognize the colors every time they need to identify a color.
Hence, the contribution of this paper is an approach where an unsupervised neural network (NN) is trained with chromaticity samples of different colors. The image is processed by the NN using the chromaticity data of the colors which is obtained by mapping, previously, the image to the HSV color space. The activation occurrences of each neuron of the NN are collected in a histogram, the number of neurons with the highest activation occurrences, number of clusters, is obtained; the image is segmented using the FCM with the number of clusters obtained.
The paper is organized as follows: in Sect. 2 we introduce our approach for segmentation. The experiments performed and the results obtained are presented in Sect. 3. In Sect. 4 the results are discussed; the paper closes with conclusions and future work in Sect. 5.

Proposed Approach
By observing their environment humans can recognize different regions within a scene by the chromaticity features, because humans identify colors mainly by the chromaticity features, later by the intensity [16,18]. For instance, we can state the color of squares (a) and (b) of Fig. 1 is green because both squares have the same chromaticity although the square (a) is brighter than square (b). On the other hand, we can claim the colors of squares (c) and (d) are different because the chromaticities of both squares are different despite the intensities are the same. Humans do not have to learn the colors every time they need to recognize a given color; they just use the knowledge acquired previously. Thus, the steps of our proposal are: (1) train a NN with chromaticity samples of different colors; (2) map the image to the HSV space and extract the chromaticity of each pixel's color of the given image; (3) the chromaticity of each pixel is feeded to the NN trained previously; (4) the activation occurrences of each neuron are collected in a histogram; (5) the number of peaks of the histogram is computed, it defines the number of clusters; (6) the number of clusters is updated by comparing the chromaticity of the neurons with the highest activation occurrences; (7) the image is segmented with the number of clusters obtained in step 6 using FCM.
The number of clusters is updated because there may be neurons with similar chromaticity and occurrence number; that is, the colors these neurons recognize are almost the same, so, they belong to the same section and they must be grouped in the same cluster.

Chromaticity Characterization
The RGB (Red, Green, Blue) color space is based in a Cartesian coordinate system where colors are points defined by vectors that extend from the origin, where black is located in the origin and white in the opposite corner to the origin, see Fig. 2.
The color of a pixel p is written as a linear combination of the basis vectors red, green and blue [16]: Where r p , g p and b p are the red, green and blue components, respectively. The orientation and magnitude of a color vector defines the chromaticity and the intensity of the color, respectively [16]. This color space is sensible to non-uniform illumination; even if two vectors with the same chromaticity but with different intensities, they represent different colors.
Thus, we employ the HSV (Hue, Saturation, Value) color space to represent colors because the chromaticity is decoupled from the intensity [16]; also, in [18] is claimed this space emulates the human perception of color. Figure 3 shows the cone shaped of the HSV space, where the color of a pixel p in the HSV space is written as [16]: Where h p , s p and v p are the hue, saturation and value components, respectively. The hue is the chromaticity, saturation is the distance to the glow axis of black-white, and value is the intensity. The real ranges of hue, saturation and value are ½0; 2p, ½0; 1, and ½0; 255, respectively.
The chromaticity is distributed around the circumference of the cone; black is located at the cone's tip and white at the center of the base at the bottom of the cone. Black and white are not chromaticities, they can be defined as a low value color and low saturation color, respectively.
The chromaticity is characterized as a vector because of the case when the hue is almost 0 or 2p. Consider squares (c) and (d) of Fig. 1, their hue values are p=100 and 19p=10, respectively. Numerically both values are very different but the chromaticities of both squares are similar; if the chromaticity of both squares is classified only by the scalar values, the chromaticity would be recognized as if they were very different. Thus, this problem is overcome as follows; let u p be the color of a pixel in the HSV space represented as in Eq. (2), the chromaticity is modeled as:

Neural Network Training
In this study we perform experiments with a CNN and a SOM. These kind of unsupervised NNs are based on finding the index of the winning neuron before external stimuli. The difference between these NNs lies in the training. In a CNN, only the weight vector of the winning neuron is updated; while in a SOM, where the neurons are set in a specific array, the weight vector of the winning neuron and the weight vectors of the neighbor neurons are updated. The weight vectors of the neurons are updated with the Kohonen learning rule [19]. Because of the fuzzy nature of color, it is not possible to recognize all the colors of the spectrum; hence, the color spectrum is "divided in" a finite amount of colors. The number of colors the NN can recognize depends on its size; in this paper we perform tests with a CNN with 16 neurons and a SOM also with 16 neurons set in a 4 × 4 array.
Therefore, both NNs can recognize up to 16 different colors. Both NNs are trained with the elements of the set W built with chromaticity samples as follows:

Computing the Number of Clusters
Computing the number of clusters or sections of the image involves performing the following operations to each pixel of the image: 1. The pixel / ¼ ½r; g; b is mapped to the HSV space obtaining the vector u ¼ ½h; s; v 2. Verify if the color of the pixel is black by comparing its intensity with respect to a threshold value. That is, if v\d v then the occurrence for black is collected in the histogram, go to step 6. 3. If the color is not black then it is verified if the color of the pixel is white by comparing its saturation with respect to a threshold value. In other words, if s\d s then the occurrence for white is collected in the histogram, go to step 6. The number of clusters is defined by the number of bins of the histogram greater than zero. In the histogram there are also collected the activation occurrences of the neurons which are activated a few times; it implies that there are irrelevant small parts within the image that are considered they form important parts of the image.
Hence, there must be selected just the bins whose number is large enough to represent a significant section within the image. Thus, let P be the set of indexes of the normalized histogram bins whose number is greater or equal than threshold d H : Where HðkÞ is the value of the normalized histogram at bin k. Therefore, the total of clusters c is the number of elements of the set P; in other words:

Adjusting the Number of Clusters
As stated before, there may be neurons with almost the same activation occurrences and with similar chromaticity. That is, there is a section within the image with a common color that activates two neurons several times; therefore, such section of the image is segmented in two parts. Due to the colors are almost the same it means they must be grouped in the same cluster. Thus, the colors of the neurons with the highest activation occurrences are compared by computing the orientation difference between the weight vectors of the neurons as follows: Where Dh i;j is the orientation difference between the weight vectors w i and w j of neurons i and j, respectively. If the orientation difference is smaller than the threshold value d h then the number of clusters must be reduced. That is: Where c a is the number of similar colors. The final number of clusters c t is: Finally, the image is segmented using the FCM with c t clusters. It is important to mention the image is processed with the colors represented in the RGB space.

Experiments and Results
Lately the Berkeley Segmentation Database 1 (BSD) is becoming the benchmark for testing segmentation algorithms of color images. We select randomly a set of 12 images, shown in Fig. 4, from the 300 color images the BSD contains. For experiments we employ the following threshold values: d H ¼ 0:001 and d h ¼ p=6, for both NNs. Figure 5 shows the images obtained using the CNN. Table 1 shows the number of clusters computed and the final number of clusters obtained for segmentation for each image processed by the CNN.
The final number of clusters is computed with Eq. (9); i.e., the total of clusters minus the number of similar colors. Figure 6 shows the images obtained using the SOM with 4 × 4 neurons. Table 2 shows the number of clusters computed and the final number of clusters obtained for By observing Tables 1 and 2, the SOM recognizes more colors than the CNN; but also, there are reduced more similar colors using the SOM. It is notable the appearance difference between the images of Figs. 5 and 6, where there are more colors or sections in the images obtained using the SOM. In the following section there are discussed and analyzed the results obtained.

Discussion
We claim, from the images shown in Sect. 3, it is possible to estimate the number of colors within an image by processing it using a NN trained with chromaticity samples, without training it every time an image is processed. The segmentation of the images using both NNs is, to some extent, similar because there are computed almost the same number of clusters; but the SOM recognizes more colors than the CNN. We perform a discussion about it in Sect. 4.1 On the other hand, the colors of the images, processed by the FCM, are represented in the RGB space, but in this space the chromaticity is sensitive to the intensity, we discuss in Sect. 4.2 how the segmentation is affected if the vectors are normalized and then processed by the FCM.

Comparison Between Both Neural Networks
Despite both NNs are trained with the same training set and with the same number of neurons, the number of colors they recognize is different although they process the same images. The segmentation of the images 1, 2, 3, 5, 6, 7, 9, 10, 11 and 12 obtained using both NNs is very similar because the final numbers of clusters are the same or almost the same. For instance, in image 1 it is computed 6 clusters using the CNN and 7 employing the SOM; in image 10 it is computed 7 clusters employing the CNN and 9 using the SOM; in image 12 it is computed 5 clusters using the CNN and 7 employing the SOM. In other images it is computed the same final number of clusters using both NNs; specifically images 3, 5, 6 and 7.
The images where the appearance difference is more notable, depending on the NN employed, are the images 4 and 8. In the image 4 processed by the CNN, the color corresponding to the grass area has the same green hue; but in the same section of the image, processed by the SOM, is segmented with two different kinds of green hue. In image 8, the grass and the house are segmented with the same color using the CNN; while using the SOM the grass and the house are segmented with different colors.
The SOM recognizes more colors, but when the number of clusters is adjusted, there are obtained values similar to the number of clusters obtained using the CNN. The plausible explanation is the architecture of the SOM emulates the geometric shape of the HSV about the chromaticity, that is, the base of the cone, see Fig. 3.

Normalizing the RGB Color Vectors
When the FCM are applied to the images, the colors of the pixels are represented in the RGB space. Despite several colors with the same chromaticity can be grouped in different clusters if their intensities vary. For instance, the image 8 of Figs. 5 and 6, the area corresponding to the water is segmented in three parts because of the intensity differences, despite the chromaticity is almost the same. Also, in image 12 of Fig. 6 and image 9 obtained with both NNs, the sky area is segmented with two intensity levels.
If only the chromaticity data is processed the segmentation changes significantly; that is, the color vectors are normalized and then they are processed by the FCM. In this way the color vectors have the same magnitude, therefore the same intensity; but the orientation does not change, so, the chromaticity does not change. Figure 7 shows the images obtained employing the CNN and normalizing the color vectors before they are processed by the FCM.
The colors of several sections are defined better, they are more homogeneous and it is easier to appreciate them. For example, in image 7 the section corresponding to the stone wall has only one kind of hue; in image 9 the sky is segmented homogeneously with the same blue hue. The segmentation of image 8 resembles the image segmentation obtained with the SOM; in the same image, using the CNN, the hue of the grass area is alike to the hue of the house, but in the same image of the Fig. 7 the same area is segmented in green hue, similar to the image obtained using the SOM.
In image 12 there are two areas segmented with different kinds of green hue, which it is not appreciated in the same image shown in Figs. 5 and 6, besides the hue of the sections are more homogeneous. We have introduced a proposal to compute the number of clusters a color image must be segmented using fuzzy c-means. We employ a competitive neural network and a self-organizing map, trained with chromaticity samples of several colors. The chromaticity data of each image's pixel is feeded to the neural networks, in a histogram there are collected the activation occurrences of each neuron. The number of the most activated neurons represents the amount of colors within the image; therefore, the number of sections or clusters. This number is adjusted by eliminating similar colors.
The performances of both neural networks are alike, although the self-organizing map recognizes more colors, when the number of clusters is adjusted, there are obtained almost the same values for both neural networks. The number of colors within the image is computed by employing only the chromaticity data; the image segmentation success without training the neural networks every time a new image is given.
As future work it is necessary to perform experiments with more images and with different threshold values d H and d h , and sizes of the neural network, so as to find optimal values for these parameters that influence the segmentation; with and without normalizing the color vectors, as shown in images of Fig. 7, the segmentation seems to be more accurate if the color vectors are normalizing before they are processed with the fuzzy c-means. The quantitative evaluation of our segmentation proposal can be computed using the probabilistic rand index and variation of information metrics along with the Berkeley segmentation database, which are becoming the standard metrics and benchmark, respectively, to compute the performance of segmentation algorithms of color images [11].