bwlabel does not count objects in the image
10 views (last 30 days)
Show older comments
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
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)
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!