I was surprized to see that the tiff written in matlab with lzw compression (62.5 Mo) was 1.7 times larger than the same file, opened in gimp, and exported to a new file, with lzw compression (36.6 Mo). Both seems to use libTiff 4.0 for image writing
I verified, the two files contain the exact same pixel value when opened in matlab, so no loosy compression happening.
The only difference I can found between the two files,
using the identify -verbose
command, the only difference is:
Gimp:
Compression: LZW
Properties:
tiff:document: /.../gimp.tiff
tiff:rows-per-strip: 128
tiff:software: GIMP 2.10.5
Artifacts:
filename: gimp.tiff
Filesize: 36.55MB
Number pixels: 24.23M
matlab:
Compression: LZW
Properties:
...
tiff:rows-per-strip: 62
Artifacts:
filename: matlab.tiff
Filesize: 62.83MB
Number pixels: 24.23M
So the only difference seems to be tiff:rows-per-strip
(128 vs 62), and the presence of tiff:document
tag in the gimp file.
I get the similar differences using Tiff()
in matlab.
I don't really see how these could cause such difference in file size...
But my real question is how to write such small file size in matlab ?
Thanks for any help!