Why imwrite command changes some pixel automatically?

2 views (last 30 days)
I run following code
then result is
Why saved image is different than image which I provided?

Accepted Answer

Guillaume
Guillaume on 28 Nov 2014
That has nothing to do with imwrite and everything to do with the image format you've used for saving the image.
Go read the wikipedia article about JPEG compression to learn more about it. In particular the first line of that section says: "JPEG uses a lossy form of compression".
If you care about the exact value of the pixels of your image do not use jpg for storing your images, use one of the non-lossy file format. One of the more versatile is png.
  2 Comments
Image Analyst
Image Analyst on 28 Nov 2014
Edited: Image Analyst on 28 Nov 2014
I second that. I use PNG whenever possible. It's rapidly becoming the new de facto standard. You should start using it also. By the way, you can also "Vote" for (like I did), as well as Accept, the answer to give Guillaume even more reputation points

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!