hms-dbmi / viv

Library for multiscale visualization of high-resolution multiplexed bioimaging data on the web. Directly renders Zarr and OME-TIFF.
http://avivator.gehlenborglab.org
MIT License
273 stars 43 forks source link

Support for "JPEG-2000 Lossy"? #774

Open Dev-Lan opened 6 months ago

Dev-Lan commented 6 months ago

User story Ome-tiff supports lossy JPEG-2000 compression. On my particular dataset I converted it with bftools -compression set to JPEG-2000 Lossy. This reduced my image file from around 1mb each to 250kb. This reduction has positive performance implications for a web application that is fetching this data. The lossy compression may be an acceptable tradeoff in some cases for smaller file sizes.

I am currently using loadOmeTiff to load my files; however this does not appear to support JPEG-2000 Lossy.

Preferred solution If loadOmeTiff supported JPEG-2000 Lossy and could decode it quickly it would give a more performant option for applications that fetch a lot of images.

Possible alternatives I tried all the compression supported by bfconvert:

Open to any other suggestions for reducing file size. The resolution of the files are not large. These are 767x767 pixels with a single channel of data. 1MB seems like could be reduced, especially if lossy compression is acceptable.

ilan-gold commented 6 months ago

@Dev-Lan If you could compile a JPEG2000 compressor to wasm (written in e.g., C), you could use it by registering it as a codec. See here for an example of how we set up the class for this for lzw. You can then register the codec with geotiff according to the integer number in the tiff file for that compression algorithm (for LZW, for example, it is 5).