July 13, 2010

Lossy v. lossless compression in JPEG 2000

The arguments for and against using JPEG 2000 lossy files for long-term preservation are largely centred around two issues: 1) that the original capture image is the true representation of the physical item, and therefore all the information captured at digitisation should be preserved; and 2) that lossy compression (as opposed to lossless compression) will permanently discard some of this important information from the digital image. Both of these statements can be challenged, and the Buckley/Tanner report went some way to doing this.

The perceived fidelity of the original captured image is the root of the attachment to lossless image formats. As cameras have improved, so has the volume of information captured in the RAW files. This volume of information has of course improved the visual quality and accuracy of the images, but this comes at the cost of inflated file sizes. A high-end dSLR camera will produce RAW files of around 12Mb. A RAW file produced by a medium-format camera may be 50Mb or higher. When a RAW file is converted to a TIFF, file sizes can increase dramatically depending on the bit-depth chosen due to interpolating RGB values for each pixel captured in the RAW file. As RAW files can only be rendered (read) by the proprietary software of the camera manufacturer (which may include plugins for 3rd party applications like Photoshop), they cannot be used for access purposes and, being proprietary, are not a good preservation format. They must be converted to a format suited to long term management, and this has usually been TIFF. When a RAW file is converted to a TIFF, file sizes can increase dramatically depending on the bit-depth chosen due to interpolating RGB values for each pixel captured in the RAW file. This bloats the storage requirements by 2 to 4 times.

However, image capture and subsequent storage of large images, is expensive, and we don't want to have to redigitise objects ever if we can get away with it - particularly for large scale projects. So, how much of a compromise is lossy compression, and is it really worth it? The question is: what information are we actually capturing in our digital images? Do we we need all that information? Is any of it redundant?

First - the visual fidelity issue. Fidelity to what information? The visual appearance of a physical item as defined by one person in a particular light? The visual appearance as perceived through a specific type of lens? All the pixels and colour information contained in the image as captured under particular conditions? No two images taken through the same camera even seconds apart will look the same due to distortions caused by the equipment, and, possibly, noise levels. What makes any particular pixel the original representation, or the most accurate, or indeed at all important?

Lossy compression will permanently discard data. What is necessary is to determine - for any given object, set of objects, or purpose - what information is actually useful and necessary to retain. We already balance these decisions at the capture stage. Choosing to use a small-format camera immediately limits the amount of information that can be detected by the camera sensor. Choosing one lens over another introduces a slightly different distortion. Compression also represents a choice between what you can capture and what you actually need. One may not need all the information that has been captured; some of it may be redundant. A lot of it may be redundant. And the point of JPEG 2000 is that it is very good at removing redundant information.

At the Wellcome Library, the aim of our large-scale digitisation projects is to provide access. We do not want to redigitise in the future, but we do not see the digital manifestations as the "preservation" objects. The physical item is the preservation copy, whether that is a book, a unique oil painting, or a copy of a letter to Francis Crick. For us, the important information captured in a digital manifestation are the human-visible properties. Images should be clear and in-focus, details visible on the original should be visible in the image (so it must be large enough to see quite small details), colour should be as close to the original as possible in daylight conditions and consistent, and there should be no visible digital artefacts at 100%. This is the standard for an image as captured.

We are striking a balance. Can we compress this image and retain all these important qualities? Yes. Do we need to retain information that doesn't have any relevance to these qualities? No. Lossy compression works for us. Using these qualities as a basis, we set out a testing strategy to determine how much compression our images could withstand.

To be continued...


Bedrich said...

Hello Christy Henshaw,
I mostly agree with your article. However migration as significant part of long-term preservation was not mentioned. In my opinion this is one of the biggest threats. My concern is; when we use lossy compression for our MC (Master Copies) in large scale what will happen with our data during future migrations? We will need to migrate, because each format becomes soon or later obsolete.
There is just an example of simple migration.
Let’s start with TIFF format /1:1 no compression/ as our MC. Due to space capability was TIFF migrated to JPEG /1:10 DCT (Discrete cosine transform) irreversible/ and the original TIFF-MC was deleted. Now we have only JPEG-MC for which we used visually lossless compression. The next step will be migration into JP2-MC /1:10 DWT (Discrete wavelet transform) irreversible/ again visually lossless compression. And the next step would be migration JP2 into “Let It Wave” /DFWW (Discrete Frequency Warped Wavelets)/ again visually lossless compression and so on.
How we can see we use, different algorithms for each migration. Each algorithm creates significantly different artifacts. I could be OK for few migrations, because we used very “light” compress ratio (visually lossless). I am highly concern that those artifacts will grow through each migration and become more and more pronounced in the future. There are other threats such as color shifts during migration process etc.
As a rather expensive process we do not want to rescan our data after set of unsuccessful migrations. In my opinion it would be better to use mathematically lossless compression for Master Copies. Each representation of data could be decompressed as it was before migration.
I would like to ask you if you know about any research which is focusing on such the issue.

Christy Henshaw said...

Hi Bedrich,

Thanks for your comment - you raise a very interesting point, and something we have factored into our thinking. We are in fact about to post on this very topic, hopefully this week.

I guess my immediate reaction to this is, while yes migration will introduce new algorithms, this should be managed in such a way that visual lossless-ness is maintained. It would also be my hope that, considering the long timescales when we think about many migrations, conversion algorithms and format design will become ever better at recreating and retaining information in an efficient way. However, I will defer this discussion to my colleague, a Digital Curator, and his upcoming blog post...

Christy Henshaw said...

Bedrich - please see post dated July 21, 2010, which addresses these issues in more detail. Cheers, Christy

Ron Smith said...

Thank you for this explanation. I've been a photographer for 50 years and digital now for almost twenty. I switch off from jpg to raw based on my output needs (once I got into the 15 megapixel range) the loss is simply not worth discussing in many of my shots without a microscope which is the only way to discover that there WAS loss!

I do have one question for you though. In an "average" jpg file compression how much of that compression is lossy and how much lossless? I know it depends on redundant information.. I'm just trying to get a handle on a RAW file reduced to 10% of its original size in a jpg. It can't all be loss.

Ron Smith

Christy Henshaw said...

Hi Ron,

Thanks for your comment. We are talking about JPEG 2000 specifically here (which is a completely different format to JPEG, although the name is confusing!). Do you mean to ask about JPEG 2000, or JPEG?

Regarding how much compression is lossy and how much is lossless - with JPEG 2000 (.jp2/.jpf) you can choose to compress lossless (a more effecient way to store data, but all the data is retained), and lossy, where data is actually discarded. Much of the discarded data is noise. I'm not sure about the JPEG format though (.jpg) - I don't think there is a lossless option.