-
Notifications
You must be signed in to change notification settings - Fork 5
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
[Feature Request] Image compression for ome.tiff files #87
Comments
Hey @mfs4rd! We do already use image compression in OME TIFF writing: https://github.com/bioio-devs/bioio/blob/main/bioio/writers/ome_tiff_writer.py#L298 Are you asking to allow users to choose which compression to use? I don't personally see a problem with that cc @toloudis. Seems like a simple parameter addition |
we have another issue for ome-zarr also I think : #36 |
@evamaxfield Derek has recently been using tiff.imsave(output_path, cp.asnumpy(img), photometric='minisblack', compression='zlib',compressionargs={'level': 8}) He claims it gave him a 345:1 compression on segmentations that he has been working with. I don't know how this compares to the method currently used but it might be worth giving this option to users. |
we absolutely should provide this as an optional parameter for tiff as well. and consider changing the default if it makes sense to. I suspect that adobe deflate and zlib will be similar for segmentations but who knows! |
I have opened a PR to move the compression from hard coded to a parameter on the writer. Note @mfs4rd during my quick investigation of tifffile, I found that zlib is simply a different name for our default compression scheme of "adobe_deflate": https://github.com/cgohlke/tifffile/blob/master/tifffile/tifffile.py#L1941 PR will still open up the option for people to parameterize the compression scheme but I am curious if y'all are seeing a difference in file size on disk between the two schemes and the docstring hasn't been updated on tifffile's side? |
Feature Description
Include the ability to use image compression when saving
ome.tiff
files by providing additional input arguments inOmeTiffWriter().save()
that are passed on totifffile.imsave()
ortifffile.imwrite()
. This feature could also be implemented for other file formats if possible.Use Case
Using image compression to save image segmentation or intermediate images used for analysis could help to reduce storage space on hard drives and network storage. Segmentation images are often sparse and comprised of large regions of identical pixel values, making them easy to compress to a substantial degree with minimal loss. Likewise raw images can also be compressed in scenarios where loss is a negligible concern.
Solution
Image compression parameters already exist in
tifffile
, whichOmeTiffWriter()
wraps. We need only provide these same arguments as optional parameters toOmeTiffWriter().save()
that are passed down totifffile.imwrite()
when writing the image to disk, and include relevant documentation explaining options to users. Additional messaging to users about this feature to help in adopting it as standard practice can be discussed.The text was updated successfully, but these errors were encountered: