Question

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:

image with imshow(), it appears the same when I save

Whereas with imageview():

enter image description here

Can some one help me?

Was it helpful?

Solution 2

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));

OTHER TIPS

I think that you should use imshow(uint8(image)); on the image before displaying it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top