How to make the binarized image clearer
Afficher commentaires plus anciens
my_image = imread('image026.gif');
my_image = my_image(:,:,1);
BW = imadjust(my_image);
BW = imbinarize(my_image);
imtool(BW)
I am using the above code to change the 'image026.gif' to binary, however it comes out as 'binary.bmp' which is due to the threshold of the imbinarize() function. I was wondering how can I change the threshold to make it more clear.
Réponse acceptée
Plus de réponses (1)
darova
le 20 Sep 2019
Pay attention that you don't extract colormap
This only extracts indexed image (see workspace, I is of size [369x574x1])
I = imread('image026.gif');
imshow(I)
And this how it looks originally

Try
[I,map] = imread('image026.gif');
I0 = ind2rgb(I,map); % convert indexed to rgb
thresh = graythresh(I0);
I1 = im2bw(I0,thresh); % binarize image
conn = 4;
I2 = bwareaopen(~I1,5,conn); % remove areas with more than 5 pixels
% I3 = imdilate(I2,ones(3)); % can be dilated a bit
subplot(211)
imshow(I0)
subplot(212)
imshow(~I2)
Result

Catégories
En savoir plus sur Image Type Conversion dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!