## 3 Cell Extraction
### Sputum Cell Detection
#### 3.1.2 Bayesian Classification  
In this approach we address the cell detection problem using a probabilistic method based on the Bayesian classification [19]. In these methods, a pixel \(x\) is considered part of the sputum region if \(p\) (_bg/x_) \(<\)_p_ (_sp/x_) where _sp_ and _bg_ refer to the sputum and the background respectively. Applying the Bayesian Rule and the concept of classification cost, this inequality can be brought to:  
\[\sigma=\frac{\mu_{{}_{sp}}}{\mu_{{}_{bg}}}\frac{p(bg)}{p(sp)}<\frac{p(x|sp)}{p( x|bg)} \tag{8}\]  
where \(\mu_{{}_{sp}}\) is the loss weight incurred if the sputum class has been selected instead of the background and \(\mu_{{}_{bg}}\) is the loss weight incurred if the background class has been selected instead of the sputum, _p_(_bg_) and _p_(_sp_) are the probabilities of the background and the sputum classes respectively, and they are estimated from the total number of sputum and background pixels in the training set of images according to the following equations:  
\[p(sp)=\frac{T_{{}_{sp}}}{T_{{}_{sp}}+T_{{}_{bg}}} \tag{9}\] \[p(bg)=\frac{T_{{}_{bg}}}{T_{{}_{sp}}+T_{{}_{bg}}} \tag{10}\]  
where _T_{{}_{sp}}\) and _T_{{}_{bg}}\) are the numbers of sputum and background color respectively.  
The setting of the ratio \(\frac{\mu_{{}_{sp}}}{\mu_{{}_{bg}}}\) is based on the following reasoning. In the context of cancer cell detection, false positives are usually prevailed over false negatives. Bearing in mind that cancerous cells are characterized by oversized nucleus-relatively to the cytoplasm, mistakenly selecting a background pixel as a sputum pixel, does somewhat increase the detected cytoplasm region, thus disproportioning the nucleus, and thus increasing the likelihood of assessing the cell as being a non-cancerous cell. From this prospect, the loss incurred of a false sputum cell classification should be allotted a larger weight than its counterpart in the opposite case (e.g., loss incurred if the background class has been chosen instead of the sputum). Thus, the ratio \(\lambda=\frac{\mu_{{}_{sp}}}{\mu_{{}_{bg}}}\) should be set larger than 1.  
The class-conditional _pdfs_ _p_(_x_/_sp_) and _p_(_x_/_bg_) were estimated using the histogram technique [20]. This approach is motivated by several reasons. First, with the histogram technique, there is no need to make any assumption about the shape of the sputum and background probability density functions. In the opposite case, when a specific form of the class-conditional _pdf_ is assumed, as in the case with the Gaussian density models, some color spaces may prevail over others. Second, with the histogram technique, the Bayesian classifier can be designed very quickly even with a large training set, as compared to other classifiers such as the Artificial Neural Network. Finally, in this application, the feature space has low dimensionality.  
The histograms were computed for different color spaces (RGB, YCbCr, HSV, L*a*b). Each channel, in each color space is divided into bins (16, 32, 64, 128 or 256). Following this, the histograms are converted to discrete probability distributions by normalization. Figure 3 shows a visualization of the RGB histogram with 256 resolutions.  
**Figure 3.** 256- RGB color space Histogram visualization for the sputum and non-sputum pixels.  
Figure 4 shows some examples of sputum cell extraction obtained with two different values of the ratio \(\lambda\). We can observe that the size of the detected cell for \(\lambda=7\) is less than its counterpart for \(\lambda=2\). This observation confirms our reasoning regarding the appropriate range of this ratio.  
**Figure 4.** Samples of sputum cell extraction results. From left to right: raw images, ground truth data, cell detection with \(\lambda=2\), and cell detection with \(\lambda=7\).