Save a matrix as an image

Viewed 6082

I have a matrix finalMat of data type double with values in the range of 0 to 255. It actually corresponds to some image. I am displaying it as below:

imshow(finalMat, []);

But when I try to save it using the below code, the image saved is completely white.

imwrite(finalMat,'myImage.jpeg','JPEG');

I want to save the image on disk without changing the values in the finalMat matrix. When I read the saved image i.e myImage.jpeg, I must get the same values as in finalMat. Can somebody please help in saving the image?

1 Answers
Related