im2bw get different binary results on same data between double and uint8 in R2016a
2 views (last 30 days)
Show older comments
Hi, I am using im2bw to convert a RGB image to binary, but get very different results when image was in uint8 or double format.
How does this difference appear?
which results should I trust?
Thanks.
a= [];
a(:,:,1) = [ 1 2 6 7 6;
1 1 8 7 8;
1 1 9 6 7;
1 2 7 8 6;
1 2 6 8 7];
a(:,:,2) = [ 0 0 0 0 0;
0 0 0 0 0;
0 0 0 0 0;
0 0 0 0 0;
0 0 0 0 0];
a(:,:,3) = [0 0 0 0 0;
0 0 0 0 0;
0 0 0 0 0;
0 0 0 0 0;
0 0 0 0 0];
graythresh(a)%0.4980
imshow(im2bw(a)) % shows a normal binary image
graythresh(uint8(a)) %0.0137
imshow(im2bw(uint8(a))) % shows only black. All information is lost.
0 Comments
Answers (0)
See Also
Categories
Find more on Import, Export, and Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!