How to make the binarized image clearer
이전 댓글 표시
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.
채택된 답변
추가 답변 (1개)
darova
2019년 9월 20일
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

카테고리
도움말 센터 및 File Exchange에서 Image Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!