I have got a problem, In my program i get a image as the output, When ever i save that image in any of the file formats, and then reopen the image using imread all its pixel values are changed.How can i save my image while preserving its pixel values

1 view (last 30 days)
Can anyone please tell me a way to save my image while preserving its pixel value.

Answers (2)

Walter Roberson
Walter Roberson on 11 Jul 2015
To prevent the values from changing, use an output format that does not use compression or which uses lossless compression. In particular, by default JPEG uses lossy compression and the values change for JPEG unless you tell it to turn compression off. Consider using TIFF files.
  2 Comments
KUNAL JOG
KUNAL JOG on 12 Jul 2015
Thankyou Walter for your response, But even the TIFF format changes the pixel values. My actual image has pixel values ranging from 0 to 1. But when i save it in any of the formats the pixel values change to the range 0 to 255. Is thr anyway or formula to change it back to the orglly range.....

Sign in to comment.


Image Analyst
Image Analyst on 11 Jul 2015
I recommend using PNG format, though TIFF and BMP will also be OK. Definitely don't use JPEG.
  3 Comments
Image Analyst
Image Analyst on 12 Jul 2015
uint8 is what I always use for saving images (it gives the maximum portability to other programs). I'm not sure if those formats can accept floating point data in any range. If you're not going to use the image in any other program, then save the variable to a .mat file. Otherwise you'll have to look up the proper parameters to tell it to save as floating point TIFF or PNG (if that is allowed).

Sign in to comment.

Categories

Find more on Image Processing Toolbox 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!