MATLAB: Is a resaved JPG file different from the original

f not equal f1Image Processing Toolbox

when i read any image and then write it without any modification then read it again i found that the mattrix of them not equal there is a difference between them.
f=imread('lena.jpg');
imwrite(f,'lena1.jpg');
f1=imread('lena1.jpg');

Best Answer

JPEG is a lossy image compression format, and the amount of loss can be adjusted. The loss settings that were used to create the image might not be the same loss settings that are used by default when you imwrite() a JPEG image, so the imwrite() / imread() combination might be throwing away more information than was thrown away to create the original lena.jpg file.
Also notice that your code has you reading the same file twice :)