Retrieve pixel values from the output jpeg image I have this jpeg image (abc.jpg) and I change some pixel values of this image and store this on hard disk, to later see the changed the pixel values. The name of the output jpeg image is say, xyz.jpg. The problem here is in the image xyz.jpg. The changed pixels does not give me the exact values which I changed them to. 

Example:

In abc.jpg at the pixel position (x,y)=(1,10) the pixel value is (231, 120, 120). Now, I want to change it to (230, 120, 120). Now, I save this output image as xyz.jpg. When I try to retrieve the values from position (1,10) I get the pixel value as (232, 120, 120). Now you see the problem, I can't get the value to which I have changed. I am doing all this in MATLAB. And yes, I have tried to save the output image as .tiff, .bmp, .gif. But the size of these formats is very large as compared to .jpg. Please suggest some solution to this problem.
Ask yourself: why do you think the TIFF and BMP files are so large while JPEG files are small?

Answer: JPEG is a lossy compression format and achieves small file size by removing details from your image imperceptible to the human eye. By design, JPEG cannot guarantee that the decompressed image will be pixel-by-pixel identical to the compressed image - it just preserves the overall content the human eye can perceive. You could try increasing the quality parameter, but this probably won't solve the problem in your case. Brightness levels will still be quantized, and color information downsampled.

Some "solutions":


Do not use JPEG, use a lossless compression format.
Do your image editing/modifications directly in the compressed domain. I doubt there are tools in Matlab to do that, and compressed-domain image modification is not as straightforward as writing into an array of pixels!