SciELO - Scientific Electronic Library Online

vol.36 número1Prós e Contras da reabilitação assistida por computadorQuantificação automatizada de Ki-67 em tecido epitelial gástrico com base na razão de área dos núcleos celulares índice de autoresíndice de assuntospesquisa de artigos
Home Pagelista alfabética de periódicos  

Serviços Personalizados




Links relacionados

  • Não possue artigos similaresSimilares em SciELO



versão On-line ISSN 2215-3470versão impressa ISSN 1011-0275

Uniciencia vol.36 no.1 Heredia Jan./Dez. 2022 


An efficient convolutional neural network to detect and count blood cells

Eficiente red neuronal convolucional para detectar y contar los glóbulos de la sangre

Rede neural convolucional eficiente para detecção e contagem dos glóbulos sanguíneos

Rakesh  Chandra Joshi1

Saumya Yadav2

Malay  Kishore Dutta3

Carlos M. Travieso-Gonzalez4

1 Centre for Advanced Studies, Dr. A.P.J. Abdul Kalam Technical University, Lucknow, U.P., India.,

2 Centre for Advanced Studies, Dr. A.P.J. Abdul Kalam Technical University, Lucknow, U.P., India.,

3 Centre for Advanced Studies, Dr. A.P.J. Abdul Kalam Technical University, Lucknow, U.P., India. Corresponding autor.,

4 Institute for Technological Development and Innovation in Communications (IDeT-IC), University of Las Palmas de Gran Canaria (ULPGC), Las Palmas de G.C., Spain.,


Blood cell analysis is an important part of the health and immunity assessment. There are three major components of the blood: red blood cells, white blood cells, and platelets. The count and density of these blood cells are used to find multiple disorders like blood infections (anemia, leukemia, among others). Traditional methods are time-consuming, and the test cost is high. Thus, it arises the need for automated methods that can detect different kinds of blood cells and count the number of cells. A convolutional neural network-based framework is proposed for detecting and counting the cells. The neural network is trained for the multiple iterations, and a model having lower validation loss is saved. The experiments are done to analyze the performance of the detection system and results with high accuracy in the counting of the cells. The mean average precision is achieved when compared to ground truth provided to respective labels. The value of the average precision is found to be ranging from 70% to 99.1%, with a mean average precision value of 85.35%. The proposed framework had much less time complexity: it took only 0.111 seconds to process an image frame with dimensions of 640×480 pixels. The system can also be implemented in lowcost, single-board computers for rapid prototyping. The efficiency of the proposed framework to identify and count different blood cells can be utilized to assist medical professionals in finding disorders and making decisions based on the obtained report.

Keywords: convolutional neural network; deep learning; platelets, red blood cells; white blood cells


El análisis de células sanguíneas es una parte importante de la evaluación de la salud y la inmunidad. Hay tres componentes principales de los glóbulos rojos, los glóbulos blancos y las plaquetas. El recuento y la densidad de estas células sanguíneas se utilizan para encontrar múltiples trastornos como infecciones de la sangre como anemia, leucemia, etc. Los métodos tradicionales consumen mucho tiempo y el costo de las pruebas es alto. Por tanto, surge la necesidad de métodos automatizados que puedan detectar diferentes tipos de células sanguíneas y contar el número de células. Se propone un marco basado en una red neuronal convolucional para la detección y el recuento de las células. La red neuronal se entrena para las múltiples iteraciones y se guarda un modelo que tiene una menor pérdida de validación. Los experimentos se realizan con el fin de analizar el rendimiento del sistema de detección y los resultados con alta precisión en el recuento de células. La precisión promedio se logra al analizar las respectivas etiquetas que hay en la imagen. Se ha determinado que el valor de la precisión promedio, oscila entre el 70% y el 99,1% con un valor medio de 85,35%. El coste computacional de la propuesta fue de 0.111 segundos, procesar una imagen con dimensiones de 640 × 480 píxeles. El sistema también se puede implementar en ordenadores con CPU de bajo costo, para la creación rápida de prototipos. La eficiencia de la propuesta, para identificar y contar diferentes células sanguíneas, se puede utilizar para ayudar a los profesionales médicos a encontrar los trastornos y la toma decisiones, a partir de la identificación automática.

Keywords: red neuronal convolucional; aprendizaje profundo; glóbulos rojos; glóbulos blancos


O exame de células sanguíneas é uma parte importante da avaliação de saúde e imunidade. Há três componentes principais dos glóbulos vermelhos, glóbulos brancos e plaquetas. A contagem e a densidade dessas células sanguíneas são usadas para encontrar múltiplos distúrbios, tais como infecções no sangue: anemia, leucemia, etc. Os métodos tradicionais são demorados e o custo dos testes é alto. Portanto, surge a necessidade de métodos automatizados que possam detectar diferentes tipos de células sanguíneas e contar o número de células. É proposta uma estrutura baseada em rede neural convolucional para a detecção e contagem de células. A rede neural é treinada para múltiplas iterações e é salvo um modelo que tem uma menor perda de validação. São realizados experimentos para analisar o desempenho do sistema de detecção e os resultados com alta precisão na contagem de células. A precisão média é obtida analisando os respectivos rótulos na imagem. Foi determinado que o valor médio de precisão oscila entre 70 % e 99,1 % com um valor médio de 85,35 %. O custo computacional da proposta foi de 0,111 segundos, processando uma imagem com dimensões de 640 × 480 pixels. O sistema também pode ser implementado em computadores com CPUs de baixo custo para prototipagem rápida. A eficiência da proposta, para identificar e contar diferentes células sanguíneas, pode ser usada para ajudar os profissionais médicos a encontrar distúrbios e tomar decisões, com base na identificação automática.

Palavras-chave: Rede neural convolucional; aprendizagem profunda; glóbulos vermelhos; glóbulos brancos


Blood is composed of four major components, namely red blood cells (RBC) or erythrocytes, white blood cells (WBC) or leukocytes, platelets or thrombocytes, and plasma. Plasma is the fluid component of the blood, which includes proteins and dissolved salts. RBCs and platelets are found in the blood in large numbers, while WBCs are only 1% of the total blood cells. About 40-45% of blood cells are RBCs; they play a major role in carrying oxygen to other tissues. WBCs are responsible for the immunity of the body against infections. Platelets aid in clotting the blood and saving from excessive loss of blood.

Counting blood cells is an important parameter analyzed by doctors and medical professionals to check patients’ health. Microscopic blood cell analysis is still used to diagnose multiple diseases such as leishmaniasis, trypanosomiasis, filariasis, and malaria. The number of blood cells is large, and instruments like hemocytometers took longer to count blood cells. These instruments have chances of error and depend on the skills of the pathologist. Hence, it arises from the need for an automated system for blood cells detection and counting of different blood cells. The blood smear image analysis can give more information when training images of different blood cells in neural networks to develop an accurate and robust system.

An image processing-based method to count RBCs is proposed by Acharya & Kumar (2018), where normal and abnormal cells were identified for an input blood smear image. For this purpose, the K-medoids algorithm is used to extract WBCs from a blood smear image, and granulometric-based analysis is performed to separate WBCs and RBCs. Circular Hough Transform and labeling are used to count the number of cells. Another image processing-based RBC counting method is presented where thresholding is done for different pixels of HSV converted images (Cruz et al., 2017). Counting blood cells is done using the connected component labeling. Circular Hough transform (Acharjee et al., 2016), CHT (Sarrafzadeh et al., 2015), SVM, and spectral angle imagining (Lou et al., 2016) are also used to count different blood cells. ResNet and Inception net-based pre-trained models were used to count WBC from the image after segmentation using color space analysis (Habibzadeh et al., 2018). An iterative circle detection algorithm is also used to find RBCs and WBCs (Alomari et al., 2014). Another method has been presented for segmenting and counting RBCs using pulse-coupled neural networks (Ma et al., 2016). Counting cells is based on the average size of RBC, which can create mismatching in some cases. The blood cell counting using different deep learning models is compared on BCCD datasets which achieved the highest mean average precision (mAP) of 74.37% (Alam & Islam, 2019).

The main contribution of this paper is an automatic blood cell detection and counting framework. The dataset of 364 images having 4888 blood cells is labeled and divided into training, validation, and test set. The whole dataset is used to train convolutional neural networks in different batch sizes. The performance of the trained model is analyzed in different parameters. Bounding boxes were made around the detected blood cells. Mean average precision is high. The average precision of WBCs is more than 97% for all models. The counting error is much less for detected blood cells with a detection threshold of 0.9, and WBCs cells give 100% accurate results on counting. The detection time for processing one blood smear image of size 640×480 pixels takes

0.11 seconds. The proposed system can assist pathologists and medical professionals in making decisions based on the predicted output.

Blood Cell Image Dataset

In this study, the blood cell images database was collected from an opensource repository; it is the Blood Cell Count Dataset (BCCD), which has 364 images of blood cells. These images contain 4888 different cells: 4155 RBCs cells, 372 WBCs cells, and 361 platelets (BCCD, 2020). Figure 1 shows RBCs, WBCs, and platelets on an input blood smear image. The deep learning model is trained with 256 images, and the model is validated with 54 blood cell images. Once the model is generated, it is tested with 54 blood cell images having 800 different blood cells, and counting is performed.

Note: derived from research.

Figure 1 Different Blood cells. 

Proposed Method

Artificial intelligence is significantly transformed with the arrival of deep learning (LeCun et al., 2015; Krizhevsky et al., 2017). This technology is a part of machine learning that is utilized to solve complex problems with state-of-the-art performance on computer vision and image processing (Alom et al., 2018). Deep learning models have been widely used on medical images, giving high results in detection, segmentation, and classification tasks. Proper annotation and labeling are performed on collected blood cell images by using the “LabelImg” application, which is further divided for training, validation, and test ing set. The dataset images are trained with convolutional neural networks (CNN) to generate a model to perform detection of different blood cells from the test blood cell images and perform the counting of the recognized blood cells. An overview of the proposed work is shown in Figure 2 for the detection and counting of the blood cells.

CNN is named after a mathematical operator known as convolution. In the CNN architecture with multiple numbers of layers stacked on it, the convolution layer extracts features from the input image dataset by applying filters on it. Computational performance is enhanced with a max-pooling layer that reduces the dimensionality of layers. The final layer for performing classification tasks is known as the fully connected layer. CNN consists of these layers, and to perform classification and detection tasks, internal parameters of these layers are adjusted.

Instead of developing a deep learning model from scratch, a more coherent approach is to design the architecture utilizing already established CNN models. Therefore, Darknet-53 architecture is used for this study as a backbone network that increases the speed of object detection from the input image. Darknet-53 has 53 layers trained

Note: derived from research.

Figure 2 Methodology of the blood cell detection. 

Note: derived from research.

Figure 3 Architecture of the proposed model on processed data. 

on ImageNet datasets (Krizhevsky et al., 2017). Then, these layers were stacked with 53 more layers of YOLO-v3 algorithm to perform the detection task. The proposed work has a state-of-the-art architecture design for blood cells detection. Figure 3 shows the schematic diagram of the proposed work with processed data.

The input blood cell images are divided into N X N grids. Grid cells are responsible for detecting objects if the centers of the objects lie in those grid cells: they predict bounding boxes and determine the confidence score associated with those boxes. YOLO-v3 calculates bounding boxes on three different scales like features pyramid network (Lin et al., 2017), and these prediction results are more significant for detecting minor-sized blood cell targets. The algorithm was already trained on COCO datasets (Lin et al., 2014) and implemented using pre-trained weights.

The input blood cell images are divided into N X N grids. Grid cells are responsible for detecting objects if the centers of the objects lie in those grid cells: they predict bounding boxes and determine the confidence score associated with those boxes. YOLO-v3 calculates bounding boxes on three different scales like features pyramid network (Lin et al., 2017), and these prediction results are more significant for detecting minor-sized blood cell targets. The algorithm was already trained on COCO datasets (Lin et al., 2014) and implemented using pre-trained weights. Predictions were made on three different scales in the proposed work, as shown in Fig. 3. Thus, an input smear image of 416 x 416 dimension was divided into grids of 13 × 13, 26 × 26, and 52 × 52 for the respective stride values of 32, 16, and 8. The confidence score describes the confidence of the model that the object lies in the box and the accuracy of the box it predicted. Each grid in the input image predicts B bounding boxes with confidence scores and C class conditional probabilities. The confidence score formula is given in equation 1:

where represents the common value between predicted and reference bounding box and pred(Obj) = 1, if the target is in the grids, otherwise it would be 0.

Experiment and Results

A convolutional neural network needs to be trained and tested to develop a framework for blood cell detection. For this purpose, an Intel Xenon processor with 64 GB RAM and an NVIDIA Quadro P600 graphics processing unit (GPU) with 24 GB graphics memory are used. Image pre-processing, training, and testing are done on Anaconda3 (Python 3.7), and other libraries, such as TensorFlow and OpenCV, required to train the model. The statistics of the number of images in the datasets are given in Table 1.

A dataset from all sources is divided for training, testing, and validation in 70%, 15%, and 15%, respectively. The deep learning model is trained with blood cell images containing 4888 cells for several iterations until the loss becomes saturated. Generated trained models are analyzed with multiple images in test datasets to obtain overall performance. Yolo-v3 based convolutional neural network is trained for 400 epochs with an initial learning rate of 10-3 and IoU of 50%.

The training is done for different batch sizes of 4, 8, and 16 images. Its steps in each epoch are 512, 256, and 128 while training in a batch size of 4, 8, and 16, respectively. Once trained, models are tested with never-seen blood cell smear images. Some of the tested results are shown in Figure 4, where various blood cells are detected with a higher percentage using the proposed framework.

Average precision (AP) is a measure that integrates recall and precision for good results. It splits into 4 kinds to perform a binary classification on the image: true positive TP, false negative FN, true negative TN, and false positive FP, according to the fusion of predicted class and labeled class of the proposed model. Average precision is the mean of the precision scores after every significant document is retrieved. The formula to calculate precision and mean average precision is given in equation 2:

where Q is the number of queries. Table 2 shows the AP value of trained objects.

Table 1 Dataset description. 

Parameters Original Dataset Training Set Validation Set Test Set
Number of Images 364 256 54 54
Blood Cells 4888 3437 651 800
RBC 4155 2910 552 693
WBC 372 263 54 55
Platelets 361 264 45 52

Note: derived from research.

Note: derived from research.

Figure 4 Result of the generated detection model. 

Table 2 Result of maps from different cells. 

Blood Cells Average Precision (IoU = 0.5)
  Batch Size = 4 Batch Size = 8 Batch Size = 16
RBC 0.6729 0.7133 0.7024
WBC 0.9753 0.9933 0.9919
Platelets 0.8164 0.8504 0.8662
Mean Average Precision 0.8215 0.8523 0.8535

Note: derived from research.

Different batches achieve the highest accuracy for different cells. Batch size 8 gives the highest AP for WBC and RBC. Instead, batch 16 returns the highest AP for platelets and the highest mAP value that is 85.35% on 0.5 IoU. The performance of the deep learning model depends on the detection and counting of different cells from the input blood cell image. The statistical analysis is done to count different blood cells where the counting of RBC, WBC, and platelets is compared with the ground truth value of different samples. For WBC counting with all three trained CNN models, accurate results reached 100%. The counting range for RBC is -6 to 7 for different batches. Table 3 shows the counting error (CE) for different blood cells in various error ranges; it also displays most test images that gave zero errors.

The performance of model trains in a batch size of 16 gives the best result with the least counting errors and the highest mAP value with 85.35% higher than the models used in (Alam & Islam, 2019).

The computation time to process the image frames having dimensions of 640×480 pixels is 0.111 seconds, and about 9 frames can be processed per second using the NVIDIA Quadro P600 GPU. Blood cell detection and counting can be done fast and accurately.

The YOLO-v3 detects the blood cells in three different scales. The system can work in real time and give accurate outputs, especially WBCs. This system can help pathologists and medical professionals with rapid analysis to provide recommendations and consultation to patients based on the generated report.


This paper proposes the robust and fast detection and counting of different blood cells. The images of different blood cells with respective labels are provided to train the deep learning model with multiple parameters. The trained model is analyzed on different parameters. The results show high accuracy while detecting and counting the blood cells.

Table 3 Counting errors using different trained models. 

Parameters Batch Size = 4 Batch Size = 8 Batch Size = 16
  RBC WBC Plat. RBC WBC Plat. RBC WBC Plat.
Range -10 to 5 0 -1 to 1 -6 to 6 0 -1 to 2 -6 to 7 0 -1 to 2
CE = 0 7 54 38 7 54 40 10 54 36
0 < CE ≤ ± 1 11 0 16 17 0 12 13 0 17
0 < CE ≤ ± 2 23 0 16 23 0 14 27 0 18
CE > ± 2 24 0 0 24 0 0 17 0 0

Note: derived from research.

The proposed framework can scan the image in three different scales, making it easy to detect the small-sized blood cells in an input image frame. Average precision ranges from 0.70 to 0.991 with a mean average precision value of 0.8535. The input images frames were processed very fast; the resulting count of different cells can be utilized by doctors to find disorders based on that report. The complete framework is automatic, and multiple images frames can be processed subsequently to generate the report. The proposed automated framework is significantly more accurate and faster than the traditional methods used by pathologists.

Conflict of Interest

The authors declare no competing interests.

Author contribution statement

All the authors declare that the final version of this paper was read and approved. Total contribution by the authors towards conceptualization, preparation, drafting, and editing of this article is as follows: R.C.J. 25%, S.Y. 25%, M.K.D. 25%, and C.M.T.G. 25%.

Data Availability Statement

Data sharing is not applicable since no new data was created or analyzed in this study. The data supporting the results of this study will be made available by the corresponding author, M. K. Dutta, upon reasonable request.

Ver anexo


Acharjee, S.; Chakrabartty, S.; Alam, M. I.; Dey, N.; Santhi, V.; & Ashour, A. S. (2016). A semiautomated approach using GUI for the detection of red blood cells. 2016 International Conference on Electrical, Electronics, and Optimization Techniques (ICEEOT), 525-529. https:// [ Links ]

Acharya, V. & Kumar, P. (2018). Identification and red blood cell automated counting from blood smear images using computer-aided system. Medical & Biological Engineering & Computing, 56(3), 483-489. [ Links ]

Alam, M. M. & Islam, M. T. (2019). Machine learning approach of automatic identification and counting of blood cells. Healthcare Technology Letters, 6(4), 103-108. [ Links ]

Alom, M. Z.; Taha, T. M.; Yakopcic, C.; Westberg, S.; Sidike, P.; Nasrin, M. S.; Van Esesn, B. C.; Awwal, A. A. S.; & Asari, V. K. (2018). The History Began from AlexNet: A Comprehensive Survey on Deep Learning Approaches. ]

Alomari, Y. M.; Sheikh Abdullah, S. N. H.; Zaharatul Azma, R.; & Omar, K. (2014). Automatic Detection and Quantification of WBCs and RBCs Using Iterative Structured Circle Detection Algorithm. Computational and Mathematical Methods in Medicine, 2014, 1-17. [ Links ]

BCCD. (2020). Blood Cell Count Dataset. GitHub, Inc. ]

Cruz, D.; Jennifer, C.; Valiente-Castor, L. C.; Mendoza, C. M. T.; Jay, B. A.; Jane, L. S. C.; & Brian, P. T. B. (2017). Determination of blood components (WBCs, RBCs, and Platelets) count in microscopic images using image processing and analysis. 2017IEEE 9th International Conference on Humanoid, Nanotechnology, Information Technology, Communication and Control, Environment and Management (HNICEM), 1-7. [ Links ]

Habibzadeh Motlagh, M.; Jannesari, M.; Rezaei, Z.; Totonchi, M.; & Baharvand, H. (2018). Automatic white blood cell classification using pre-trained deep learning models: ResNet and Inception. In J. Zhou; P. Radeva; D. Nikolaev; & A. Verikas (Eds.), Tenth International Conference on Machine Vision (ICMV 2017) (p. 105). SPIE. https://doi. org/10.1117/12.2311282 [ Links ]

Krizhevsky, A., Sutskever, I. & Hinton, G. E. (2017). ImageNet classification with deep convolutional neural networks. Communications of the ACM, 60(6), 84-90. [ Links ]

LeCun, Y.; Bengio, Y.; & Hinton, G. (2015). Deep learning. Nature, 521(7553), 436-444. [ Links ]

Lin, T.-Y.; Dollar, P.; Girshick, R.; He, K.; Hariharan, B.; & Belongie, S. (2017). Feature Pyramid Networks for Object Detection. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 936-944. https://doi. org/10.1109/CVPR.2017.106 [ Links ]

Lin, T.-Y.; Maire, M.; Belongie, S.; Hays, J.; Perona, P.; Ramanan, D.; Dollár, P.; & Zitnick, C. L. (2014). Microsoft COCO: Common Objects in Context (pp. 740-755). In: Fleet D.; Pajdla T.; Schiele B.; Tuytelaars T. (eds) Computer Vision - ECCV 2014. ECCV 2014. Lecture Notes in Computer Science, vol 8693. Springer, Cham. [ Links ]

Lou, J.; Zhou, M.; Li, Q.; Yuan, C. & Liu, H. (2016). An automatic red blood cell counting method based on spectral images. 2016 9th International Congress on Image and Signal Processing, BioMedical Engineering and Informatics (CISP-BMEI), 1391-1396. https://doi. org/10.1109/CISP-BMEI.2016.7852934 [ Links ]

Ma, Rong; Liang, Yuanzhi; & Ma, Y. (2016). A self-adapting method for RBC count from different blood smears based on PCNN and image quality. 2016 IEEE International Conference on Bioinformatics and Biomedicine (BIBM), 1611-1615. [ Links ]

Sarrafzadeh, O.; Dehnavi, A. M.; Rabbani, H.; Ghane, N.; & Talebi, A. (2015). Circlet based framework for red blood cells segmentation and counting. 2015 IEEE Workshop on Signal Processing Systems (SiPS), 1-6. https:// [ Links ]

Received: October 26, 2021; Accepted: January 07, 2022

Creative Commons License This is an open-access article distributed under the terms of the Creative Commons Attribution License