How to counting RBC size and number

1 vue (au cours des 30 derniers jours)
Nora Hamad
Nora Hamad le 27 Août 2021
Réponse apportée : Vinay le 27 Jan 2025
i write this code but i cant get number of rbc and this is my input image
clear all;
close all;
clc;
count=0;
RC_Im = imread('red_cells.png');
RC_Im = rgb2gray(RC_Im);
level=graythresh(RC_Im);
RC_Im_BW = im2bw(RC_Im,level);
figure;
imshow(RC_Im_BW,[])
[x,z]=size(RC_Im_BW);
for R=0:1:60
SE = strel('disk',R);
afteropen=imopen(RC_Im_BW,SE);
if RC_Im_BW==1
count=count+1;
end
end
figure;
imshow(afteropen,[])

Réponses (1)

Vinay
Vinay le 27 Jan 2025
The binary image comparison 'RC_Im_BW==1' compares the entire image rather than individual objects.The 'bwlabel' can be used to label connected components in the binary image which counts the number of distinct objects.
%morphological operations
RC_Im_BW_cleaned = imopen(RC_Im_BW,strel('disk', 5));
% Label connected components
[labeledImage, numRBCs] = bwlabel(RC_Im_BW_cleaned);
% Print the count of RBCs
fprintf('Number of RBCs: %d\n', numRBCs);
Refer to the below documentation of 'bwlabel' for more details.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by