# A Cell Counting Framework Based on Random Forest and Density Map
## 1 Introduction  
In biomedicine and pathology, the number of cells is a significant indicator of cell analysis. Initially, the counting task is executed by naked eyes and the result is sensitive to many objective factors, such as the parameters of the microscope, the image contrast, non-uniform illumination, various shapes and sizes, or the overlap of cells. In these circumstances, the counting task becomes more difficult and time-consuming. Furthermore, the counting result may vary from person to person. To automate the process of counting and make the task easier to be implemented, many algorithms have been proposed. With the prior information about the appearances of cells, some morphology-based methods extract cells from the background [1; 2; 3]. They can only handle well the images with separated cells. To count the overlapped cells, the density-based model is proposed [4]. The density-based model learns the relationship between the input cell image and density map which can be integrated to obtain the number of cells. Considering the powerful feature representation, convolutional neural networks (CNNs) are often used to learn the mapping from the source domain to the target domain. The non-linear mapping makes it possible to fit any function. However, CNN has too many parameters to set and it is not friendly to the non-professionals. More importantly, the backpropagation requires a large number of floating point operations, which means it is almost impractical to train a network on central processing unit (CPU) and graphics processing unit (GPU) support is necessary. By contrast,random forest (RF) has fewer parameters to set and it can be trained on CPU efficiently. In terms of this, RF is more likely to be applied in practice. There have been some models and applications based on RF [5; 6]. Reviewing the algorithm of RF, it predicts by collecting the values of inputs that arrive at the same leaf node. Namely, it is the statistics of the subset of inputs. When the cells in the testing set are more crowded or less crowded than the cells in the training set, the density value is out of the input scope. In this circumstance, the prediction will always be lower or higher than the ground truth. Therefore, it is not proper to directly predict the density map via RF. To solve this problem, we proposed a cell counting framework (CCF) based on RF to predict the density map by detecting cells. First, we defined a probability map as the ground truth to make sure that the centroids of cells can be detected even when cells are overlapped. With the well-prepared training data, cells can be detected robustly by Hessian matrix on the output of RF. The proposed CCF contains multiple RFs that have various decisions about the cell detection result. To decrease the risk of false detection, we averaged all detection results and turn the average into the density map by Gaussian function. In this way, the accuracy can be improved. Compared to the traditional counting methods based on detection [7] or density map [5], our proposed CCF has the following advantages. (I) Cell detection is sensitive to the output of RF. The proposed method combines various detection results to decrease the count error and improves the robustness. (II) With the same number of decision trees (DTs), using multiple small RFs can avoid overfitting better than using a large RF. (III) Traditional density map prediction aims to recover the pixel-wise density value, so the pixel-wise error is aggregated which is related to the total count error. Using RFs to predict the probability map to detect cells has a lower accuracy requirement than the density map prediction. Besides that, we also extracted the feature patch with a stride to reduce the computational overhead. In summary, the contributions of this paper are as follows:  
1. We defined a probability map to describe the cell locations.