.st0{fill:#FFFFFF;}

RBC and WBC Blood Cell Counter using Circular Hough Transform 

 June 14, 2019

By  Ceethal Piyus

Get Access to
Code, Image & Report!

Learn the image segmentation concepts to analyze and count red and white blood cells in MATLAB and App Designer. Create a project based on RBC & WBC Segmentation; Updated & Tested in MATLAB R2023B with App Designer.

Cover picture : RBC and WBC Blood Cell Counter

Introduction

What would healthcare look like if you could determine your blood cell count as quickly and inexpensively as your body temperature? At MATLAB Helper®, we are excited by this possibility and believe that such a future is within sight, thanks to MATLAB Image processing and segmentation techniques!

This blog will demonstrate a simple example of how image processing and segmentation techniques can classify and estimate blood cell count.

The proposed model will segment white blood cells (WBC) and Red blood cells (RBC) and it will count them despite they are overlapped or not, by using an algorithm called Circular Hough transform. 

Before entering into the algorithm, let's see why this is a fascinating problem space in the first place!

Estimation of Blood Cells and why they’re crucial?

A microscopic image of the blood smear is often used to categorize and identify disease conditions that can affect blood cells and to track down those who seek treatment for these conditions. There are many diseases that can affect the count and type of blood cells produced, their function, and their lifespan. Examples include bone marrow disorders, anemia, and leukemia. So understanding the count of Blood Cells in our bloodstream can give us a powerful picture of our health.

Disease affecting Blood cell counts

Fig1: Examples of disease conditions that affects Blood cell counts

Old conventional method using Hemocytometer and microscope are involving manual counting of blood, which are extremely laborious, time-consuming, and leads to inaccurate results due to human errors. Also, there are some expensive machines like Analyzer, which are not affordable by every laboratory. The proposed method that we will be covering through the rest of this blog is a potentially promising advancement over such techniques due to the following reasons:

  • Instantaneous results
  • Low cost
  • Accurate
  • less human interactions

Now that we have the necessary background, let’s jump into our particular problem and analyze the dataset, methodology, and results of our method.

Problem: 

Given a stained image of a blood smear sample, classify it as either RBC or WBC and estimate it’s count despite its overlapped or not.

RBC WBC segmentation Image

Fig 2: Expected outcome

  •  

Dataset

The project was fully implemented in MATLAB; the main advantage of this algorithm is that the model does not require training for segmentation. Image segmentation steps are followed for identifying RBC and WBC present in the sample, so it works for the segmentation in smaller data sets. The dataset is composed of a dyed blood sample with overlapped and not overlapped cells. Each image is in PNG format, which is of 440 x 440 pixels size.

Blood smear samples

Fig 3: Blood smear samples used in our dataset

Prerequisites required

  • MATLAB App designer and Image processing toolbox
  • Blood smear samples

Graphical User Interface

For creating the graphical user interface, watch the video given  below!

Graphical user interface design using MATLAB app designer tool box

Fig 4: Graphical user interface design using MATLAB app designer tool box

Algorithm Design

The main criterias considered in this method for segmenting RBC and WBC are its shape and size, normally the RBC’s are having a shape similar to circular shape and WBC’s are irregular in shape. Regarding the size, WBC’s are larger than RBCs. So keeping this in mind we are going to create an algorithm to segment RBC and WBC from the blood sample. The whole algorithm can be summarized as follows:

Algorithm design

Fig 5: Algorithm design

Results

Step1: Image acquisition and Pre-processing

Step2: Segmentation of WBC’s and RBC’s

Step 3: Segmentation of WBC

Step 4: Counting of WBC

Step 5: Segmentation of RBC

Step 6: Circular Hough transform for counting overlapped RBC’s

Conclusion

We hope the results and methodology shared here provide an overview of how promising image processing and segmentation tools are in the field of cell imaging and classification.
As you can see in the picture below, this algorithm was even successful in three overlapping areas for counting the RBC.

Overlapped cells identified through Circular Hough Transform

Fig 18: Overlapped cells identified through Circular Hough Transform

In certain cases the stains are misclassified as cells but, this algorithm differentiates the stains from RBC cells based on its circular shape and counts only the RBC’s.

Correctly predicted RBC cells by eliminating stain issues

Fig 19: Correctly predicted RBC cells by eliminating stain issues

The model and problem statement discussed in this blog are simple, and we believe that they can be extended to more complex issues with multiple classes, new cell types and more varying illumination conditions. We encourage you to extend this code not only for WBCs and RBCs but also a wide variety of other cells such as platelets, sickle cells, and even acanthocytes. If you have any queries regarding the algorithm or if you stuck with your code, you can type them in the comment section below and we will help you with that 🙂 !

If you have any requirement similar to this and you are looking for expert's help, do send the email with necessary attachment at [email protected]

Limitations

Reference:

Watch the video below for the full code and try to replicate all the results yourself 🙂 


Get Standalone Application of Webinar

This Standalone has been created using MATLAB R2018b. Get the application running and start exploring RBC and WBC Blood Cell Counting.

Standalone Application Installation Steps

Get instant access to the code, model, or application of the video or article you found helpful! Simply purchase the specific title, if available, and receive the download link right away! #MATLABHelper #CodeMadeEasy

Ready to take your MATLAB skills to the next level? Look no further! At MATLAB Helper, we've got you covered. From free community support to expert help and training, we've got all the resources you need to become a pro in no time. If you have any questions or queries, don't hesitate to reach out to us. Simply post a comment below or send us an email at [email protected].

And don't forget to connect with us on LinkedIn, Facebook, and Subscribe to our YouTube Channel! We're always sharing helpful tips and updates, so you can stay up-to-date on everything related to MATLAB. Plus, if you spot any bugs or errors on our website, just let us know and we'll make sure to fix it ASAP.

Ready to get started? Book your expert help with Research Assistance plan today and get personalized assistance tailored to your needs. Or, if you're looking for more comprehensive training, join one of our training modules and get hands-on experience with the latest techniques and technologies. The choice is yours – start learning and growing with MATLAB Helper today!

Education is our future. MATLAB is our feature. Happy MATLABing!

About the author 

Ceethal Piyus

    • Ceethal Piyus says:

      Thank you for your valuable Feedback!

    • Ceethal Piyus says:

      Thank you for the feedback. You can also subscribe to our Youtube channel at https://mlhp.link/YouTube for upcoming events

    • Ceethal Piyus says:

      Thank you for your valuable Feedback!

    • Ceethal Piyus says:

      Thank you for your valuable Feedback!

    • UWAMAHORO Raphael says:

      Great work

    • Ceethal Piyus says:

      Thank you for the feedback. You can also subscribe to our Youtube channel at https://mlhp.link/YouTube for upcoming events

    • Ceethal Piyus says:

      Thank you for the feedback. You can also subscribe to our Youtube channel at https://mlhp.link/YouTube for upcoming events

  • Kazi Ziaul Hassan says:

    Hi @Ceethal Piyus,
    It would be very helpful to me if you provided the code as well as some data sets of microscopic blood sample image.

    • Hello Kazi. We don’t share code for our Webinars but we do share the Standalone Application. The Standalone application for the current topic is added in the end of this blog. You can use that for your research purpose. For code you will have to follow step by step process from the video only! All the best!

  • Hi! Would it be possible to get access to the code you presented here for research purposes? Thanks!

    • Hello Fareeha. We don’t share code for our Webinars but we do share the Standalone Application. The Standalone application for the current topic is added in the end of this blog. You can use that for your research purpose. For code you will have to follow step by step process from the video only! All the best!

  • Shardul Pawar says:

    algorithm will fail when the RBCs are completely stacked one above another is the limitation right! do we have a different approach to overcome that?
    I am curious to know wether we can process two or more 2D images of a 3D object (consider any)from different orientations and give an aggregate result giving more precise and accurate information of the object

  • SUDHARSANAN S says:

    In which unit rbc count is expressed here…..?????
    how to convert this count value to normal unit…????

  • Omar Alkousa says:

    Hello
    Thank you so much for your good explanation. I followed the steps and I and understood the essence of the project, although I don’t have that much experience in image processing.
    But I have a question about counting RBCs. I dowloaded the Hough Transform function and read it well. But I can’t make the algorithm that much of accurate because of the optional inputs control.
    So could you suggest a good values for radrange, grdthres, fltr4LM_R, and multirad so it can fits with the RBCs counting.
    Thanks in advance

  • Hozzatul Islam Sayed says:

    This is so good and i saw your video in YouTube about the blood cell count.

    But i have a problem, i need the source code and data sample figure of your video.

    Could you please provide the source code and data sample figure?

    It’s will help me a lot. If possible please provide me.

    Thank you

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    MATLAB Helper ®

    Follow: YouTube Channel, LinkedIn Company, Facebook Page, Instagram Page

    Join Community of MATLAB Enthusiasts: Facebook Group, Telegram, LinkedIn Group

    Use Website Chat or WhatsApp at +91-8104622179

    >