6 Mins Read

Using Computer Vision to Identify and Count Blood Cells helps in medical diagnosis

blood cells

Using Computer Vision to Identify and Count Blood Cells helps in medical diagnosis

Nowadays, people are more concerned about their health and routine clinical check-ups are a growing trend. A complete blood cell (CBC) mainly consists of 40-45% red blood cells (RBCs), 1% white blood cells (WBCs), and platelets. RBCs deliver oxygen to body tissues. The RBCs count highly affects the amount of oxygen received by tissues. WBCs defend the body by eliminating infections, and platelets help with blood clotting. The conventional method for CBC identification and quantification suffers from time-consuming and erroneous procedures. Moreover, the skill of clinical laboratorians and the precision of the laboratory equipment extremely affect the precision and accuracy of test results.

Alam and Islam from Bangladesh University of Engineering and Technology devised a “you only look once” (YOLO) object detection and classification algorithm to automate CBC identification and quantification. The proposed approach can be fully automated, is fast and accurate, and doesn’t need grayscale conversion or binary segmentation.

Among various algorithms for object detection, YOLO algorithms exhibit superior speeds compared to Faster R-CNN with VGG-16 architecture. YOLO is a subgroup of neural networks designed to directly predict bounding boxes and class probabilities for an image. In this paper, the authors use YOLO frameworks for identifying and quantifying RBCs, WBCs, and platelets from blood smear images. The model’s accuracy is evaluated by a verification approach and its generalization level is measured by comparing it to other datasets.

We retrain YOLO frameworks to automatically identify and count RBCs, WBCs, and platelets from blood smear images. To improve the counting accuracy, a verification method has been developed to avoid repeated counting by the framework. Also, the trained model has been tested with images from another dataset to observe the generalization of the method.

Image processing and machine learning approaches are two primary methods for automatic CBC counting. By employing the K-medoids algorithm to extract WBCs from the image and granulometric analysis to separate the RBCs from WBCs, researchers can automatically count RBCs, and identify normal and abnormal cells in the blood smear image. Additionally, the number of cells can be estimated by a labeling algorithm and a circular Hough transform (CHT). The number of platelets can automatically be evaluated by applying a CHT in a microscopic blood cell image according to the size and shape of platelets.

On the other hand, WBCs can automatically be identified, classified, and quantified in microscopic images using a CNN-based algorithm. Pre-trained CNNs, like ResNet and Inception Net, are utilized for counting WBCs in segmented images.

How can computer vision models identify and count CBCs?

The workflow for developing a computer vision (CV) model to accurately identify and count CBCs is shown in Figure 1.

 CBC identification and quantification
Figure 1. The workflow for  CBC identification and quantification. Source

Dataset gathering

To train the YOLO model, a public dataset of annotated blood cell images known as the Blood Cell Count Dataset (BCCD) is used by the authors. The BCCD consists of 364 annotated smear images, divided into the train (300) and test (60) subgroups. The validation set is randomly chosen from the training images with annotations (60). The modified dataset can be downloaded here. Another dataset including 100 images, with a resolution of 3246 × 2448 pixels captured with a Nikon V1 camera mounted on a Nikon ECLIPSE 50i microscope with a magnification of 100x, is used for the comparison purpose.

YOLO algorithms approach object detection like a regression problem. They can rapidly predict both image classes and locations using only one forward propagation pass through the network. Images with 448 × 448 pixels are split into 7 × 7pixel grid cells and each predicts two bounding boxes and confidence scores for the boxes. The network architecture includes 24 convolutional layers and 2 fully connected layers using GoogLeNet. The authors used the fastest algorithm, Tiny YOLO, which uses 9 instead of 24 convolutional layers.

Dataset training

The Tiny YOLO model is trained for 20 different classes. To achieve higher accuracy for blood cell identification, the model is optimized for three additional classes, WBC, RBC, and platelets. For each bounding box, five values along with class probabilities are predicted. These values include the probability for the presence of an object in a grid cell, the x and y coordinates of the object, and the height and width of the object.

The authors obtain loss and moving average loss in each step of the training process for a total of 4500 steps using two different learning rates of 10-5 and 10-7 for steps 1–2500, and 2501–4500, respectively. A lower learning rate in the latter steps results in a better convergence. The learning curve of the YOLO framework for blood cell identification is depicted in Figure 2. The minimum moving average loss occurred on step 3750 at the learning rate of 10−7.

YOLO framework for blood cell identification
Figure 2. The learning curve of the YOLO framework for blood cell identification. Source

Blood cell identification and counting method

The threshold value is calculated by averaging the absolute error between ground truths and the model estimation at different threshold values. The threshold for each class equals a minimum average absolute error in the validation dataset. The proposed model occasionally double counts platelets, which is solved by using K-nearest neighbor (KNN) and intersection over union (IOU) in each platelet.

For counting cells, the authors employ class labels. In fact, the trained model returns three kinds of labels: ‘RBC’, ‘WBC’, and ‘Platelets’. The total number of ‘RBC’ labels shows the number of RBCs in a smear image. Figure 3 displays a platelet detection example in which a platelet is detected twice by the YOLO algorithm. This issue is tackled using the proposed KNN and IOU-based technique.

Platelet detection in blood smear images
Figure 3. Platelet detection in blood smear images, (a) Counting the same platelet twice, (b) Discarding spurious prediction using the proposed method. Source

Model performance in predicting the type and count of CBCs

As grid cells with no blood cells exhibit low confidence, redundant and false predictions can be avoided by choosing an appropriate confidence threshold. These values are reported as followed:

  • RBC: confidence threshold of 55%,
  • WBC: confidence threshold of 35%,
  • Platelets: confidence threshold of 25%.

The resulting accuracy for RBC detection is 96.1% with a confidence threshold of 55% (Table 1). Although from Table 1 it seems the trained model is counting extra RBCs, the authors mention that the ground truth labels were not present for some of the RBCs located at the edge of the image.

Table 1. The proposed model accuracy for various types of blood cells.

accuracy for various types of blood cells

Figure 4 shows all the WBC and platelets are identified with no error while one RBC in the middle is missed and another RBC at the edge of the image is detected but is not present in the ground truth.

Ground truth labels of cells
Figure 4. (a) Ground truth labels of cells in a smear image, and (b) Automatically estimated labels of cells by the proposed model. Source

Beyond training blood cell detection models with the Tiny YOLO algorithm, the authors employ other popular CNN architectures such as VGG-16, ResNet50, InceptionV3, and MobileNet CNN. For all the networks, the training loss curves associated with validation mean average precision (mAP) values are calculated and demonstrated in Figure 5. The results imply that InceptionV3 and ResNet50 achieve the lowest error.

Loss curves for other popular CNN networks with the YOLO algorithm
Figure 5. Loss curves for other popular CNN networks with the YOLO algorithm. Source

The accuracy of RBC, WBC, and platelets counting for various CNN networks as well as the related mAP and execution time on the test set is presented in Table 2. The Tiny YOLO architecture reveals the highest accuracy of 96.1% and 96.4% for counting RBCs and platelets, respectively. However, for counting WBCs, both VGG-16 and InceptionV3 achieve the highest accuracy of 100%. ResNet50 hits the highest mAP value. The proposed approach is extremely fast and requires less than a second even for deeper networks to complete.

Table 2. Accuracy, mAP, and execution time for detecting different cells using various CNN architectures with YOLO algorithms.
Accuracy, mAP, and execution time for detecting different cells using various CNN architectures with YOLO algorithms

Other datasets are also examined by the authors to guarantee the independence of the trained model. Figure 6 displays that the RBCs, WBCs, and platelets can be detected with satisfactory performance using the proposed model.

blood cell detection
Figure 6. The blood cell detection for images from another dataset. Source


We investigated the Automatic identification and quantification of complete blood cells from a smear image using a YOLO algorithm in this paper. The KNN and IOU algorithms are proposed to effectively correct multiple counting of platelets and the resulting model can accurately identify and count RBCs, WBCs, and Platelets. Employing various neural networks in the YOLO backend proves that the best accuracy with different cell types can be achieved by various algorithms. However, the proposed approach is extremely fast for counting and marking cells in smear images. The model’s generalization is also examined, resulting in a satisfactory performance. The authors concluded that the suggested model can successfully be applied for real-time blood cell detection and quantification.

If you need more information about how AIEX experts can help you and your business, please feel free to contact us.

Related articles
Trauma Detection on Pelvic Radiographs using Computer Vision Algorithms
A timely and accurate diagnosis of the proximal femur and pelvis injuries in trauma patients is essential to saving...
Detecting and classifying aesthetic defects in different sizes, shapes, and positions immediately after the casting process is an essential...
deep learning
Nowadays with the help of computer vision technology and image processing we can classify broken and normal bone X-ray...
Annotating Computer Vision Projects
Choosing the right images for training, validating, and testing computer vision algorithms will significantly affect your AI project's success....
Metaverse is one of the fastest-growing technologies today. A comprehensive review of computer vision concepts in Metaverse is presented...
casting defects
Automated X-ray systems are improving quality through multiple objective inspections, and reducing labor costs, and increasing productivity and consistency...
Subscribe to our newsletter and get the latest practical content.

You can enter your email address and subscribe to our newsletter and get the latest practical content. You can enter your email address and subscribe to our newsletter.