You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The jpeg compression does not write blocks of 8x8 pixels and can be improved.
See comment in ome/ome-codecs#29 (comment): "... Tif images saved with JPEG compression (at high quality settings) are larger than the original uncompressed image. ..."
I tested different combinations of JPEG quality, interleaved mode and chroma subsampling and found that the size of the saved tiff files was larger than the original in almost all combinations.
To test a possible improvement, I made a change in loci.formats.tiff.TiffSaver in the writeImage() function.
My change forces 8 lines per strip when saving, resulting in jpeg compression in blocks of 8x8 pixels (what is normally used in jpeg).
I have tested the different combinations with this modified code.
Here is a comparison of the file size in bytes. (All files that are larger than the original are marked in bold.) File used for testing: lena-std.tif (786572 bytes) (available at e.g. https://imagej.nih.gov/ij/images/)
interleaved
jpeg-quality
chroma-subsampling
Unmodified TiffSaver
Modified TiffSaver
no
0.95
no
1668225
364087
no
0.95
yes
1668225
364087
no
0.7
no
1121273
169081
no
0.7
yes
1121273
169081
yes
0.95
no
1083658
202473
yes
0.95
yes
914820
163099
yes
0.7
no
625754
89538
yes
0.7
wC
599917
85053
This test clearly shows that the storage of jpeg-compressed tiff files can be improved.
My code change is NOT as a solution. It was only for my testing and is meant as a hint.
The jpeg compression does not write blocks of 8x8 pixels and can be improved.
See comment in ome/ome-codecs#29 (comment):
"... Tif images saved with JPEG compression (at high quality settings) are larger than the original uncompressed image. ..."
I tested different combinations of JPEG quality, interleaved mode and chroma subsampling and found that the size of the saved tiff files was larger than the original in almost all combinations.
To test a possible improvement, I made a change in loci.formats.tiff.TiffSaver in the writeImage() function.
My change forces 8 lines per strip when saving, resulting in jpeg compression in blocks of 8x8 pixels (what is normally used in jpeg).
I have tested the different combinations with this modified code.
Here is a comparison of the file size in bytes.
(All files that are larger than the original are marked in bold.)
File used for testing: lena-std.tif (786572 bytes) (available at e.g. https://imagej.nih.gov/ij/images/)
This test clearly shows that the storage of jpeg-compressed tiff files can be improved.
My code change is NOT as a solution. It was only for my testing and is meant as a hint.
I added a short statement in https://github.com/ome/bioformats/blob/d566f70845be514ab9c88d910ae42ab7a5f0bac0/components/formats-bsd/src/loci/formats/tiff/TiffSaver.java#L313C7-L318C64
Original code
My version
The text was updated successfully, but these errors were encountered: