How to convert image from double to uint8 in matlab? -
i have image i
of type double
. want convert image double
uint8
. have tried using both:
i=uint8(i)
i=im2uint8(i)
.
when use imshow(i)
command, black image , nothing else. doing wrong?
the im2uint8
function assumes double
image scaled range [0,1]
. if image has values larger 1
or smaller 0
, these values clipped. see following example:
im2uint8([-1 0 0.5 1 2]) ans = 0 0 128 255 255
the solution scale input image [0,1]
subtracting minimum value , dividing total range:
i = (i - min(i(:))) / (max(i(:)) - min(i(:))); = im2uint8(i); imshow(i);
Comments
Post a Comment