Converting from grayscale to binary image gives error

Hi everybody I convert my image from grayscale to binary image, however, the result is completely black. I attached my code and images. Could you please help me with that?
if true
grayImage=imread('20x.png');
binaryImage = im2bw(grayImage,0.4);
binaryImage = imfill(binaryImage, 'holes');
imshow(binaryImage, []);
end

 采纳的回答

jonas
jonas 2018-8-13
编辑:jonas 2018-8-13
The threshold (0.4) is too high. Reduce the threshold (to e.g. 0.2) or use imbinarize instead of im2bw (recommended).

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by