-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -quality
option to bfconvert
#4171
Conversation
This primarily affects JPEG compression with TIFF, OME-TIFF, and DICOM output. Fixes ome#3370.
In particular, this will make use of any provided quality value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the HEAD of the branch, executing the following conversion commands
./tools/bfconvert -compression JPEG test.fake test_jpg.tiff
./tools/bfconvert -compression JPEG test.fake test_jpg.ome.tiff
./tools/bfconvert -compression JPEG test.fake test_jpg.dcm
./tools/bfconvert -compression "JPEG-2000 Lossy" test.fake test_j2k.tiff
./tools/bfconvert -compression "JPEG-2000 Lossy" test.fake test_j2k.ome.tiff
./tools/bfconvert -compression JPEG -quality 0.1 test.fake test_jpg_10percent.tiff
./tools/bfconvert -compression JPEG -quality 0.5 test.fake test_jpg_50percent.tiff
./tools/bfconvert -compression JPEG -quality 1.0 test.fake test_jpg_100percent.tiff
./tools/bfconvert -compression JPEG -quality 0.1 test.fake test_jpg_10percent.ome.tiff
./tools/bfconvert -compression JPEG -quality 0.5 test.fake test_jpg_50percent.ome.tiff
./tools/bfconvert -compression JPEG -quality 1.0 test.fake test_jpg_100percent.ome.tiff
./tools/bfconvert -compression JPEG -quality 0.1 test.fake test_jpg_10percent.dcm
./tools/bfconvert -compression JPEG -quality 0.5 test.fake test_jpg_50percent.dcm
./tools/bfconvert -compression "JPEG-2000 Lossy" -quality 5.0 test.fake test_j2k_quality5.tiff
./tools/bfconvert -compression "JPEG-2000 Lossy" -quality 100.0 test.fake test_j2k_quality100.tiff
./tools/bfconvert -compression "JPEG-2000 Lossy" -quality 5.0 test.fake test_j2k_quality5.ome.tiff
./tools/bfconvert -compression "JPEG-2000 Lossy" -quality 100.0 test.fake test_j2k_quality100.ome.tiff
produced the following output
-rw-r--r-- 1 sbesson staff 132K 10 Apr 08:59 test_j2k.ome.tiff
-rw-r--r-- 1 sbesson staff 131K 10 Apr 08:59 test_j2k.tiff
-rw-r--r-- 1 sbesson staff 132K 10 Apr 08:59 test_j2k_quality100.ome.tiff
-rw-r--r-- 1 sbesson staff 131K 10 Apr 08:59 test_j2k_quality100.tiff
-rw-r--r-- 1 sbesson staff 129K 10 Apr 08:59 test_j2k_quality5.ome.tiff
-rw-r--r-- 1 sbesson staff 128K 10 Apr 08:59 test_j2k_quality5.tiff
-rw-r--r-- 1 sbesson staff 10K 10 Apr 08:59 test_jpg.dcm
-rw-r--r-- 1 sbesson staff 231K 10 Apr 08:59 test_jpg.ome.tiff
-rw-r--r-- 1 sbesson staff 230K 10 Apr 08:59 test_jpg.tiff
-rw-r--r-- 1 sbesson staff 363K 10 Apr 08:59 test_jpg_100percent.ome.tiff
-rw-r--r-- 1 sbesson staff 362K 10 Apr 08:59 test_jpg_100percent.tiff
-rw-r--r-- 1 sbesson staff 8.6K 10 Apr 08:59 test_jpg_10percent.dcm
-rw-r--r-- 1 sbesson staff 219K 10 Apr 08:59 test_jpg_10percent.ome.tiff
-rw-r--r-- 1 sbesson staff 218K 10 Apr 08:59 test_jpg_10percent.tiff
-rw-r--r-- 1 sbesson staff 9.7K 10 Apr 08:59 test_jpg_50percent.dcm
-rw-r--r-- 1 sbesson staff 227K 10 Apr 08:59 test_jpg_50percent.ome.tiff
-rw-r--r-- 1 sbesson staff 226K 10 Apr 08:59 test_jpg_50percent.tiff
For both JPEG and JPEG-2000 lossy when the target format supports it, the quality level passed to the utility is properly respected.
Additionally, the DICOM writer now allows to set options when using JPEG compression. As mentioned on Monday, the only outstanding todo is probably to document the new option in https://github.com/ome/bio-formats-documentation for the upcoming 7.3.0 release
Fixes #3370.
Builds on work in ome/ome-codecs#26 to pass a quality value (0.0 to 1.0) through to the JPEG codec. This can be tested by comparing conversions with different quality values, e.g.:
and different output formats (TIFF, OME-TIFF, DICOM). The output file size should increase as the quality increases.
Note that the JPEG writer does not currently make use of this, as it bypasses the
JPEGCodec
API.Adding to 7.3.0 for now, but we can also push to 8.0.0 if this seems more suited to a major version.