Adobe's Lightroom 4 beta is out, and among it's other enhancements, it features a new lossy compression scheme for DNG images. LR has always has lossless compression, which could usually reduce image size by up to half. However, it's not been used much, except when you used any of Adobe Camera Raw, Lightroom or the Adobe DNG converter to convert an existing raw image to DNG. The lossless compression scheme hasn't, so far as a I know, ever been used in-camera, presumably because it's quite CPU intensive.

Eric Chan was kind enough to give some details on the new lossy scheme, which I'll summarize here, together with my views. You can read the full exchange on the Adobe forums in this thread.

NOTE: This post is based on Eric's comments - the specification isn't yet available.


What is the new scheme?

The new scheme basically works as follows:
  1. It uses JPEG DCT compression - exactly the same as a normal JPEG image.
  2. The data is 8-bit, same as a normal JPEG.
  3. Data is demosaiced, also the same as a regular JPEG. 
So up till this point, a lossy DNG is pretty much the same as a regular JPEG. But there's more:


The clever bits

The new scheme has some clever bits that make a lossy DNG better than any normal JPEG. Those bits are:
  1. What Adobe call "1D perceptual mapping". What that actually is, is a tone curve, just like the sRGB tone curve in JPEG images, but a clever tone curve. 8-Bit pixel values range from 0 to 255. What Adobe are doing is to analyze the image data, and optimize the curve to the image data. So, for example, if your image doesn't have significant highlights, a "normal" JPEG image might only use values from 0 to 210, and not use 211 to 255. The new clever curve will spread the pixel values in the image over the full range of 0-255. Better still, this is done for each color channel individually. And because information on the new curve is in the image, that can by undone as soon as the image is loaded again.
  2. Dithering is used to prevent banding. With 8-bit values, there's the danger of banding, especially if a lot of post processing get done on the image. Dithering, basically adding noise (very carefully controlled and shaped noise!), helps to smooth out any banding. 
  3. The image stays in the camera's color space, rather than being compressed into the space defined by the JPEG primaries. Pretty much all modern cameras can represent colors that a standard JPEG image can't. Now there are some downsides to this - a wider color space being represented in 8-bit values can result in color banding, so we're going to have to see whether that turns into an issue or not. I'd say probably not, given the use of dithering, but we'll see over the next few months.
  4. The image remains scene referred. This is important for white balance. JPEG images have a fixed white balance of 6500k, so a white balance transform needs to be applied before they are created. That makes it difficult (not impossible, but less easy to do well) to adjust white balance later than if the data is in its "as shot" form.


Why have Adobe designed it this way?

Back when lossy compression was a just a rumor, I predicted that if lossy compression happened, it would be JPEG based. See this thread on LuLu. It's nice to be right, even if only occasionally(!)

The reason, in my opinion, is that a lot of camera chips have hardware acceleration for JPEG DCT built in to support JPEG out, so doing JPEG DCT lossy compression is "costless" in terms of CPU utilization for many modern cameras.


Analysis

So, where are we on this:
  1. Firstly, to state the obvious, if you use the new lossy compression, your file is no longer raw. The new lossy compression works by first demosiacing the image, then compressing. And that's irreversible. So, if at some time in the future, a better demosaicing algorithm comes out, you won't be able to take advantage of it.
  2. Secondly, the compression scheme is, and I can't put this any other way, an engineering abomination if your starting point was Bayer matrix type raw data, which maybe 99% of raw image data is. Here's why: When the image is demosaiced from the raw Bayer data, basically what you're doing is adding two thirds more data that is actually redundant. What demosaicing does is to interpolate, via an algorithm, two thirds of the pixels in an image. But these interpolated pixels are redundant data - they can be recreated from the original raw data just by recalculating. What is then compressed is the original raw data, plus all of this redundant data. So to get, according to Eric's data in the thread above, about a 50% reduction is data size relative to lossless compression (70% relative to no compression), you're actually firstly multiplying the data size by three, then compressing. So, what you're doing is a factor of ten JPEG compression to get a factor of between two (relative to lossless compression) and three (relative to no compression) data size reduction. All because of the two thirds of data that your compressing is actually redundant. That's just horrible.
  3. The quality of Adobe lossy DNG images are going to be very implementation dependent. In other words, there will be good implementations and bad implementations. There is no single way to do JPEG compression; a good JPEG compression engine will look at the data, and chose the best compression parameters for the image. Similarly, there are good and bad ways to do dithering. Finally, a simple way to implement the "1D perceptual mapping" would just to have a single fixed tone curve. Add together a not so great JPEG compression engine, not so great dithering, and some cutting of corners on the "1D perceptual mapping", and you have a recipe for really bad image quality. I have no doubt that Adobe implementation will be good. But I also suspect that if lossy DNG compression makes it into cameras, there will be some pretty bad implementations.

Conclusion and recommendation

Bottom line, a lossy DNG is a JPEG that's been somewhat tweaked to allow easier image adjustment later on. Which is no bad thing, but let's be clear - lossy DNG is an alternative to JPEG, not an alternative to raw.

If, in some future camera, you get the choice of either a JPEG image, or a lossy DNG image, you should almost certainly choose the lossy DNG. The data compression and sample size are the same, and there are advantages to be had from the perceptual mapping, color space and the scene referred nature of the image, as discussed above. In addition, if you want to convert an existing JPEG into DNG, e.g., because your workflow is standardized around DNG, then lossy DNG may be a good idea. You won't lose much quality, and alternate ways of converting from JPEG to DNG results in far larger files than the original.

However, if you're converting an already existing raw image to DNG, don't use lossy compression! Chances are, you'll get similar compression from lossless compression, you won't risk JPEG compression artifacts, and you'll be able to benefit from better demosaicing algorithms in the future. Even if you didn't get the same compression, my view would be that given the low cost of storage today, the trade-off just wouldn't be worth it.

Updated 13 Jan: after I wrote this post, Eric Chan, who is certainly in a good position to know, responded to a question about using lossy DNG compression as follows: "To be honest, I'm not really comfortable with the idea of lossy compressed DNG for archival storage purposes". Which probably sums it up well.
2

View comments

  1. Good news in a difficult year - all the macOS apps that I support - AccuRaw EXR, AccuRaw Monochrome, pcdMagic, CornerFix, dcpTool (both the GUI and command line version), DNG cleaner and pcdtojpeg - now are all available with native Apple Silicon versions for blazing fast performance on Apple's new "M1" processor. Download are in all the usual places.

    Enjoy.

    0

    Add a comment

  2. There's a whole slew of new camera support, including for Canon's new CR3 format.

    Updates of AccuRaw EXR, AccuRaw Monochrome, PhotoRaw are now available on the Apple App Store. These updates add support for these new cameras: Canon EOS-1D X Mark III, Canon EOS 90D, Canon EOS M50, Canon EOS M6 Mark II, Canon EOS Rebel SL3 (EOS 250D), Canon EOS R, Canon EOS RP, Canon EOS R5, Canon EOS R6, Canon PowerShot G5 X Mark II, Fujifilm XF10, Fujifilm GFX 50R, Fujifilm GFX 100, Fujifilm X-100V, Fujifilm X-A7, Fujifilm X-Pro3, Fujifilm X-T30, Fujifilm X-T4, Fujifilm X-T200, Leica Q2, Leica SL2, Nikon Coolpix P950, Nikon Coolpix P1000, Nikon D780, Nikon Z 6, Nikon Z 7, Nikon Z50, Panasonic DC-G90, Panasonic DC-G100, Panasonic DC-G110, Panasonic Lumix DC-G95, Panasonic DC-LX100 M2, Panasonic DC-S1, Panasonic DC-S1R, Panasonic DC-S5, Panasonic Lumix DC-FZ1000 II, Olympus OM-D E-M1X, Olympus OM-D E-M1 Mark III, Olympus E-PL10, Olympus OM-D E-M5, Olympus OM-D E-M10 Mark IV, Olympus TG-6, Pentax K1 II, Ricoh GR III, Sony DSC-RX100 VII, Sony A7 III (ILCE-7M3), Sony A7C (ILCE-7C), Sony A7R Mark IV (ILCE-7RM4), Sony A7S III (ILCE-7SM3), Sony a6100 (ILCE-6100), Sony a6400 (ILCE-6400), Sony a6600 (ILCE-6600),Sony HX99. 

    0

    Add a comment

  3. pcdMagic for Windows - the only currently available app that can convert Kodak Photo CD images with correct color and at full resolution - is now available on the Microsoft Windows Store.

    This great news for users:

    • The Windows Store version has a free trial mode that allows the app to be tested without any commitment.
    • The Windows store handles all updates automatically.
    • There's no need to keep track of license codes.
    The Windows store only supports the latest versions of Windows 10. However, for users of earlier versions of Windows, you can still purchase pcdMagic from the FastSpring webstore.
    2

    View comments

  4. As usual when new Leica cameras come out, I took a quick look inside a DNG from one of Leica's new Leica CL  cameras:

    1. The camera name shows as "LEICA CL"
    2. The image data is 14-bit. There is no compression used in the DNG I looked at. 
    3. The DNG version is 1.4, with a "backward version" of 1.3. There is a reason for this - DNG 1.3 allows for opcodes, which Leica use for lens correction.
    4. In the DNG I looked at, which was shot with a "Summicron TL 1:2 23 ASPH." lens, lens correction is done by a single "WarpRectilinear" operation in the DNG. 
    5. In addition to the lens correction op code, there is also a "FixBadPixelsConstant" opcode, whose function is exactly as the name states. This is the same as in the Leica Q, SL, etc.
    6. Unusually, the DNGs all contain 2 different JPEG preview images in addition to the main raw image, one of 1620x1080, and finally a full sized preview of 6000x4000. Having the full sized preview is particularly odd, as it takes up a lot of space. In the approximately 45 MB files I've seen, the full size preview typically takes up about 1.8 MB. 
    So in summary, the DNGs appear to be a bit of a hybrid of the "SL", "Q", etc style of DNG, with a single lens correction opcode, and a bad pixels correction opcode, and of the "M10" style of DNG, with a full sized preview. As I noted in my analysis of the M10 DNG, the full size preview is probably there to support viewing on mobile devices that often don't have raw decoding capability built in. 

    Finally, it's notable that the DNGs don't contain the bizarre Lightroom XMP metadata that the M10 DNGs have embedded in them. 
    2

    View comments

  5. So finally, after many years of searching, I have an answer to the question that torments all who go down the digital color rabbit hole.

    This is from XKCD, brought to my attention via an article on the Digital Transitions website about the Phase One IQ3 100mp Trichromatic.



    0

    Add a comment

  6. Back in January, when the new Leica M10 was introduced, there were claims that the improvement in dynamic range from the Leica M240 to the M10 was of the order of 1.5 to 2 stops.  At the time, I wrote that just by eyeballing the published images, I believed the improvement to be "closer to 0.5 stops than 1.5-2".

    Much to my surprise, given what I had thought to be just a basic explanation of why dynamic range is a tricky concept, the post generated a lot of push-back. And I mean a LOT.

    Well, now there is actually an independent third-party measurement available, from photonstophotos.net:


    And....(drum roll)....the improvement in DR between the M240 and the M10 is 0.55 stops. As I predicted back in January.

    You can a find whole lot more information, including a useful interactive graphing tool that allows you to compare cameras, on the photonstophotos.net site.
    0

    Add a comment

  7. dcpTool has been available for quite a while as a command line application for Windows and the Mac. But now it available in the form of an easy to use Mac app, with powerful batch processing capabilities. dcpTool for the Mac is available from the App Store.

    dcpTool allows you to:

    1. Decompile DNG Camera Profile (DCP) files in XML. The XML can then be read and edited with a simple text editor.
    2. Recompile edited XML into DCP files
    3. Remove "Hue twists" from camera profiles. 
    For more information on hue twists, see these posts:
    11

    View comments

  8. Many cameras embed lens corrections into raw the raw files that they produce. Generally, that's a good thing - straight lines stay straight, etc. For an example of lens corrections in practice, take a look at this post about the Leica SL.

    But, as the saying goes, "there is no free lunch". Lens corrections also have some downsides:

    • Lens corrections result in a small reduction in sharpness. Sean Reid, at Reid Reviews has done extensive testing on this as part of his various lens reviews, and his conclusions are clear - there is a measurable loss in sharpness.
    • Lens corrections result in some reduction in image size - the corrections inevitably result in the edges of the image curving, and the curved parts need to be trimmed off to get back to a straight edge.
    So sometimes, it's useful to be able to get an uncorrected image. Now there are some raw developer apps that allow you get to uncorrected images (AccuRaw EXR is one of them), but most mainstream apps such as Lightroom and Photoshop don't allow correction to be disabled.

    Fortunately though, there is a "simple trick" that will allow you to disable lens corrections for nearly any camera that produces raw images. What you need to do is a simple two step process:
    1. Firstly, convert the raw image to a DNG image, using Adobe's DNG converter.
    2. Then use DNG Cleaner (macOS only) to remove any opcodes.
    The resulting DNG will not have any lens correction, and you can load it into Lightroom, Photoshop, or any other app that supports DNGs.

    Why does this work? This works because whenever DNG Converter converts an image that needs lens correction, it embeds the required correction as an "opcode" into the DNG image. Lens correction opcodes as usually things like "WarpRectilinear". DNG Cleaner knows where to find these opcodes, and simply removes them, as long as you have the "Remove opcodes" checkbox selected:


    Note that in order for this to work, you need DNG converter to be using it's default settings. Specifically, Compatibility should be set to the most recent version of Camera Raw. You should definitely not be using Custom Settings with the "Linear" checkbox selected. "Linear", otherwise known as LinearRaw, bakes any corrections into the actual data in the DNG, making it impossible to remove.

    There's more information on the DNG Cleaner website.
    0

    Add a comment

  9. Those of you that have read the Leica M10 raw file analysis post will know that M10 DNGs have more baggage in them that is typically the case for a Leica DNG. I've put together a little app to clean them up, called DNG Cleaner (Mac only for the moment). For M10 DNGs this will remove:

    1. The full size image preview - that will save about 3MB
    2. The various Lightroom/Photoshop adjustments embedded in the XMP portion of the DNG - ISO dependent noise reduction settings, lens profiles, etc

    DNG cleaner will also optionally remove opcodes, and apply lossless compression. This isn't relevant to the M10, but in many other Leica cameras, e.g., the Q, the SL, etc, opcodes are used for lens correction. For an example of the SL's with and without lens correction, see my post on the subject. DNG Cleaner is what Sean Reid used to remove opcodes for his SL 50 review, which some of you will have seen.

    As ever, back up your files before using any app that is designed to modify them.

    For more information on DNG Cleaner, see the website.
    0

    Add a comment

  10. AccuRaw users might have gotten a bit of a surprise recently - AccuRaw has turned into AccuRaw EXR, and is now at version 3.

    The reason for the name change is that the focus of the AccuRaw product has changed a bit, based on what users were actually doing with it. AccuRaw has always been focussed on having highly linear color response, with no "hue twists" or other surprises in the color rendering. As it turns out, that is a very useful feature to have if you're composting stills into video - it reduces the amount of work required for color matching.

    In the world of video, especially in the professional cinematography world, the "gold standard" is to use a format such as EXR, which is a floating point format. That allows huge flexibility in the way that post processing is done. So the new version of AccuRaw, now named AccuRaw EXR, supports EXR output.

    However, it's more than just a name change. In order to really support EXR output, AccuRaw has seen major changes internally - it now has a fully floating point, non-clipping workflow. For more on why that is important, see this post.

    1

    View comments

Popular Posts
Blog Archive
About Me
About Me
My Photo
Author of AccuRaw, PhotoRaw, CornerFix, pcdMagic, pcdtojpeg, dcpTool, WinDat Opener and occasional photographer....
Loading