MATLAB: Is the image size changing

digital image processingImage Processing Toolboximagesimreadimwritesize;

dpc=imread('2D/original.tif');
imwrite(dpc,'2D/original1.tif');
Why does the size of original.tif and original1.tif images change? I have just read the image into variable named 'dpc' and then wrote the same data into other file. Can anyone please answer this question?
Thank you

Best Answer

  • .tif files do not have only the image data: they can also have metadata describing the image, such as comments and EXIF tags. When you do the new imwrite(), those attributes are not transferred.
  • .tif files can contain multiple images. Your code is only trying to read in the first image.
  • There are different storage arrangements possible in .tif files. In particular, it is optionally possible to store the data as "tiles" to make it possible to read in just part of the image at a time. When you do the imwrite() you would not be writing in tiles, which could change the output size because of differences in the overhead
  • There are different compression schemes available for .tif files. imwrite() uses "packbits" by default if you do not specify which one you want to use. The original .tif might have used something different, such as LZW.