Lossless Mirax image file conversion/size reduction

Benjamin Gilbert bgilbert at cs.cmu.edu
Tue May 5 22:58:22 EDT 2015


On 05/05/2015 09:27 AM, Ryan Murray wrote:
> In our lab we generate a lot of Mirax (mrxs) images of slides, and we
> are currently researching ways in which we can compress the images as
> much as possible (reduce file size) while still maintaining high
> quality at higher resolutions.
>
>[...]
>
> To tried to cobble together my own Mirax to JPEG2000 conversion using
> openslide/vips) by doing:
>
> vips openslideload --level 1 input.mrxs output.tiff[tile,compression=lzw]
>
> and then converting the tiff to a jp2 file using imagemagick.
>
> While this worked, the problem is that the size was only reduced by
> about 40% and it was not a 'lossless' conversion, i.e. there was a
> clear loss of quality at higher resolutions.
>
> My question is: Is there a way to perform a 'lossless' conversion of a
> mirax image in a manner analogous to how a WAV might be converted to
> an MP3 (even thought the file size is much smaller for an MP3, the
> sound quality is practically indistinguishable from a WAV to the human
> ear).

Hi Ryan,

I'm not sure what you mean by "lossless" here, since MP3 is explicitly a 
lossy file format.  All lossy compression algorithms try to throw away 
"unimportant" parts of the signal, and if you agree with the algorithm 
about what's unimportant, you will be satisfied with the results. 
Otherwise, not so much.

JP2 has lossless and lossy modes, and I don't know which one you used. 
If you did, in fact, use lossy compression, note that performing 
multiple compression-decompression cycles with lossy algorithms (the 
JPEG compression that was probably used in your MIRAX slides, plus JP2) 
can cause compression artifacts to accumulate.  Your compression 
settings will also matter, of course.  Also, as John pointed out on the 
VIPS list, you converted level 1 of the slide file, which throws away 
half your resolution.

It is generally not possible to convert whole-slide image formats in a 
completely lossless manner.  There is almost always slide metadata that 
cannot be perfectly represented in the target format.  Tile layouts 
vary, so recompression is often unavoidable.  In addition, some slide 
formats require the on-disk data to be preprocessed before it is 
presented to the user.  In the case of MIRAX slides, the on-disk format 
stores overlapping tiles, which must be properly aligned for display; in 
the lower-resolution slide levels, this alignment involves slicing and 
recombining tiles at sub-pixel resolution.  In converting your slides to 
JP2, you will necessarily discard the overlapping pixels and 
corresponding metadata from the original slide file, and will thus 
"snapshot" the state of OpenSlide's rendering system.  If a later 
version of OpenSlide has an improved implementation, and you have 
deleted the original slide files, you will be unable to take advantage 
of those improvements.

While format conversions can make sense for downstream uses (e.g., 
converting an ROI to JPEG for publication), in my opinion it's almost 
always best for the unmodified output of the scanner to be stored for 
archival purposes.  That gives you maximum flexibility for unanticipated 
future uses.  Thus -- without knowing the details of your situation -- I 
suspect that your lab would be best served by obtaining additional 
storage capacity.

--Benjamin Gilbert



More information about the openslide-users mailing list