Why does MATLAB play with the contrast of my image after saving it?

6 views (last 30 days)
I have a very weird problem that I hope someone can help me with. So Attached are two pictures of almost the exact same location in a map of a desert, one named "true" and one named "weird". The "true" image is the one I have and downloaded directly from the source in a tiff format. And the "weird" image is the true image taken into MATLAB with the following piece of code:
pictureData = imread("true.tiff");
h = imshow(pictureData);
imwrite(h.CData,"weird.tiff")
Now I don't understand why my map's colors are very slightly adjusted after saving the new image where the new image has lighter colors (the colors are almost the same I know...but still there is a noticeable difference that will skew my results)
I would like to do some analysis on my images but I am afraid that MATLAB will ruin my pictures and skew my results with this arbitrary change in colors. Is this because my images are gigantic (>50MB)? Or is it because I am saving those images incorrectly? I don't really know whats going.
  14 Comments
DGM
DGM on 23 Jul 2022
Edited: DGM on 23 Jul 2022
I used the code as I posted above. I'm not sure what the difference is.
Difference in version/environment?
Difference between 'true.tiff' and 'true.jpeg'?
What happens if you try to save the file using imwrite() directly on pictureData instead of on h.Cdata?
Ali Almakhmari
Ali Almakhmari on 23 Jul 2022
I tried all your suggestions and they didn't help..except one. I think I will downgrade to MATLAB 2019b and see if it works. I really appreciate all your help. Let me know if you have any further suggestions.

Sign in to comment.

Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!