Lossless Mirax image file conversion/size reduction

Mathieu Malaterre mathieu.malaterre at gmail.com
Wed May 6 03:48:38 EDT 2015


Ryan,

On Wed, May 6, 2015 at 4:58 AM, Benjamin Gilbert <bgilbert at cs.cmu.edu> wrote:
> 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.

I'd like to add a couple of comments after Benjamin's ones. What you
describe here is called 'visually lossless'.

I am assuming your MIRAX files are using a JPEG[*] based storage (DCT
coefficients) to get a fairly good compression ratio. If you want to
turn those JPEG tiles into a JP2 file (DWT coeffcients), you'll have
surprising results trying to convert in a lossless manner. Indeed the
artifacts created by DCT are very unlikely to be reproduced using DWT
coeffcients. In other word the file size of a JPEG file will be
smaller than it's *lossless* conversion to JP2.

Furthermore assuming you really meant 'visually lossless', in which
case you would use the lossy-JP2 conversion, you will still have issue
at the edges of the images since the JPEG compression is done on a
per-tile manner. So you'll have difficulties building a single tile
lossy JP2 from a multi-tile JPEG image. I would also recommend against
building a multi-tiles JP2 since it does not make sense to use tile
(=spatial domain) smaller than 1024x1024.

If you want to try for yourself, you can download the latest kakadu
demo tools and play with the kdu_compress command. Since kdu_compress
support BigTiff You may be able to play with some openslide demo data.
I would suggest something like this to start:

$ kdu_compress -i input.tiff -o output.jp2 -rate -,0.001 Clayers=28
Clevels=8 Corder=PCRL ORGgen_plt=yes

You should be able to open the generated `output.jp2` using kdu_show
(windows) or kdu_macshow (MacOSX).

2cts
[*] AFAIK MIRAX could use PNG and or BMP tiles which are lossless
representation, in which case your slides must be enormous and I can
understand your need to compress them for archival purposes.


More information about the openslide-users mailing list