How to counting RBC size and number

7 ビュー (過去 30 日間)
Nora Hamad
Nora Hamad 2021 年 8 月 27 日
回答済み: Vinay 2025 年 1 月 27 日
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,[])

回答 (1 件)

Vinay
Vinay 2025 年 1 月 27 日
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