bwlabel does not count objects in the image

10 views (last 30 days)
I wrote a code to count lymphocites but numObjects always says zero
IL = imread('Lymphocytes.jpg');
imshow(IL, [])
imhist(IL)
Thresh = multithresh(IL,2);
seg_I2 = imquantize(IL,Thresh);
imshow(seg_I2, [])
for i=1:size(seg_I2,1)
for j=1:size(seg_I2,2)
if seg_I2(i,j)==1
seg_I2(i,j)=3;
end
end
end
imshow(seg_I2,[])
J = imcomplement(seg_I2);
imshow(J,[])
binaryImage = J > 128;
[labeled,numObjects]=bwlabel(binaryImage,8);
  1 Comment
Image Analyst
Image Analyst on 19 Apr 2022
You're not showing us seg_I2 or J or binaryImage. Not only that, but you forgot to attach 'Lymphocytes.jpg' so we can't do anything but assume it's doing what you told it to do. Chances are binaryImage is all false. Check
maxValue = max(binaryImage)

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!