## 4 Cell Segmentation  
Image segmentation is the process of dividing the image into disjoint and homogenous regions. Its purpose is to extract the regions of interest based on the problem being solved [22]. Image segmentation is considered essential in computer vision, and it is the first step in image classification \begin{table}
\begin{tabular}{c c c c} \hline
**Performance** & **Previous** & **Improved** & **Bayesian** \\
**Measurements** & **Threshold Method** & **Threshold Method** & **Classification** \\ \hline
**Sensitivity** & 49\% & 82\% & 89\% \\
**Specificity** & 97\% & 99\% & 99\% \\
**Accuracy** & 96\% & 98\% & 98\% \\ \hline \end{tabular}
\end{table} 
Table 2: Performance of the extraction methods. Figure 8: (**a**) ROC curve of RGB space for the threshold classifier; (**b**) Accuracy measurements of the threshold classifier. and clustering. It is the bottleneck of any pattern recognition process because the quality of the final results will be highly dependent on the segmentation results. Several algorithms for medical image segmentation can be found in the literature [23]. No specific segmentation solution can be generalized, and it is entirely dependent on the problem being solved. Moreover, the segmentation algorithms are based on the detection of discontinuity and the detection of similar techniques, respectively. In the detection of discontinuity technique, the image is partitioned into sub images based on sudden changes in gray level or colors by using one of many algorithms such as point algorithms, line algorithms, and edge detection algorithms [24]. On the other hand, in the detection of similarity, the image is partitioned into sub images by using region growing, threshold, splitting and merging techniques [25]. In our contribution, we approached the cell segmentation problem using the mean shift technique. The cell segmentation aims at the partition of the sputum cell into nucleus and the cytoplasm. These regions exhibit reddish colors with different level of intensity (dark for nucleus and clear for the cytoplasm, as shown in Figure 9(a). To reduce the computing complexity we converted the sputum cell pixels to gray level. Subsequently, we performed histogram equalization in order to improve the contrast between the nucleus and the cytoplasm as in Figure 9(b). This process makes the sputum cell pixels to the next stage, namely, the segmentation using the mean shift technique [26]. Basically, the mean shift is a non-parametric iterative technique that operates on a particular density function defined in the feature space. In our application, the feature space is determined by the pixel's gray level and, if we consider the spatial information, the pixel spatial coordinates. Figure 9: Samples of sputum cells through the different segmentation stages. (**a**) Sputum cells; (**b**) Conversion to gray level; (**c**) Mean shift segmentation; (**d**) Mode merging; (**e**) Region refinement. The density function has the following form:  
\[f(x)=\frac{1}{n}\sum_{i=1}^{n}|\;H\;|^{-1/2}\;K_{H}\;(x-x_{i}) \tag{11}\]  
where \(n\) is the number of cell pixels, \(x_{i}\) is the feature vector, corresponding to the \(i\)th pixel. \(K_{H}\) is a kernel function, which should be bounded, symmetric, normalized and exponentially decreasing. The parameter \(H\) represents the bandwidth matrix which we set to the diagonal matrix having the diagonal terms (\(hc\); \(hs\); \(hs\)), where \(hc\) and \(hs\) represent the chromatic (gray level) and the spatial bandwidths. \(H\) is reduced to the scalar \(hc\) if only the chromatic level is considered. By choosing as kernel function the normal function (11) becomes:  
\[f(x)=\frac{1}{n}\sum_{i=1}^{n}(2\pi)^{-3/2}\;|\;H\;|^{-1/2}\;\;e^{-(x-x_{i})^{T }\;H^{-1}(x-x_{i})} \tag{12}\]  
Starting at an initial point, the mean shift algorithm searches for point of maximum density (also called modes) through successive shifting of the initial point in hill-climbing fashion.