问题
I have computed an image with values between 0 and 255. When I use imageview(), the image is correctly displayed, in grey levels, but when I want to save this image or display it with imshow, I have a white image, or sometimes some black pixels here and there:
Whereas with imageview():
Can some one help me?
回答1:
Matlab expects images of type double
to be in the 0..1 range and images that are uint8
in the 0..255 range. You can convert the range yourself (but change values in the process), do an explicit cast (and potentially loose precision) or instruct Matlab to use the minimum and maximum value found in the image matrix as the white and black value to scale to when visualising.
See the following example with an uint8
image present in Matlab:
im = imread('moon.tif');
figure; imshow(im);
figure; imshow(double(im));
figure; imshow(double(im), []);
figure; imshow(im2double(im));
回答2:
I think that you should use imshow(uint8(image));
on the image before displaying it.
来源:https://stackoverflow.com/questions/22428938/imshow-displays-a-white-image-for-a-grey-image