• Please use real names.

    Greetings to all who have registered to OPF and those guests taking a look around. Please use real names. Registrations with fictitious names will not be processed. REAL NAMES ONLY will be processed

    Firstname Lastname

    Register

    We are a courteous and supportive community. No need to hide behind an alia. If you have a genuine need for privacy/secrecy then let me know!
  • Welcome to the new site. Here's a thread about the update where you can post your feedback, ask questions or spot those nasty bugs!

Lens corrections in Leica raw (DNG) files

Doug Kerr

Well-known member
A while ago, Asher mentioned, rather in passing, while discussing some topic, that in some Leica cameras, a correction for the "color cast" of the lens in place was applied to the raw data before it was delivered in the raw file. In later discussions, he told me that he thought the same might be so of Hasselblad digital cameras and PhaseOne digital camera backs.

I wasn't aware of this kind of arrangement (there are so many things of which I am not aware!), and I was interested to learn more about it. I had a number of questions, including:

• If there any chance that what actually happens here is not that the correction is made to the raw data but rather that a description of the needed correction (based on the lens in place) was included in the raw file so the correction could be applied by the raw development software. (Not of course that I thought Asher was possibly confused as to the details here, but I just like to be sure.)

• Is this same thing done with regard to other lens-dependent corrections, such as vignetting and geometric distortion?

On my way to learning more about this matter, I came to realize that many (if not all) Leica cameras (not including those made by Panasonic) deliver their raw data as a DNG file.

Today I got very complete information on this from Sandy McGuffog, host of the ChromaSoft blog, and the developer of AccuRaw, a raw developing program for the Mac. Here's the scoop.

• In the Leica M system, the lenses, having mostly been designed for film cameras, typically have very little geometric distortion, but may exhibit a substantial color cast and/or (especially for wide-angle lenses) significant vignetting.

In the digital context, it is very practical, technically, to correct for both lens color casts and vignetting in the raw data (that is, to modify the raw data to effect the corrections before the raw data is delivered in the DNG file), and Leica in fact typically does that (assuming that the lens involved identifies itself to the body, which is done with an optical coding system).

Then, no later part of the processing chain need be concerned with this matter. It is as if the lens exhibited no color cast nor vignetting.

• In other Leica cameras, such as the Q series, the lenses are designed for the digital context. They are typically very low in color casts and vignetting, but may have significant geometric distortion.

It is not really practical to correct for geometric distortion in the delivered raw data. Rather, in those Leica cameras, "instructions" for applying that kind of correction are included in the raw (DNG) file, They are used to control the application of the correction while the image is being developed by external raw development software. These instructions are in the form of "opcodes" (short for "operation codes"), which we can think of as macros that perform the corrections. (The DNG format, in its present from, gladly accommodates such opcodes.)

Now, while I was seeking to lean more about this whole topic, I asked Check Westfall of Canon USA whether any Canon cameras make any kinds of "corrections" to the raw data before it is delivered in a raw file. His answer was essentially, "not that he knows of", with the caveat that Canon does not tell even him everything that goes on in a Canon raw file.

So that's what we now know here about that.

Best regards,

Doug
 
Last edited:

Jerome Marot

Well-known member
A while ago, Asher mentioned, rather in passing, while discussing some topic, that in some Leica cameras, a correction for the "color cast" of the lens in place was applied to the raw data before it was delivered in the raw file. In later discussions, he told me that he thought the same might be so of Hasselblad digital cameras and PhaseOne digital camera backs.

I don't think so. Keep in mind that the back can be exchanged in Hasselblad and Mamiya MF cameras and that third party backs are or were available (for example from Sinar). Third party backs typically do not have access to lens data, so the correction is manual. I do not think that there are obvious differences in lens profiles between the ones used for the manufacturer backs and the ones used for third party backs.
 

Doug Kerr

Well-known member
Hi, Jerome,

I don't think so. Keep in mind that the back can be exchanged in Hasselblad and Mamiya MF cameras and that third party backs are or were available (for example from Sinar). Third party backs typically do not have access to lens data, so the correction is manual. I do not think that there are obvious differences in lens profiles between the ones used for the manufacturer backs and the ones used for third party backs.

Makes sense, at least with respect to third-party backs..

Thanks.

Best regards,

Doug
 

Doug Kerr

Well-known member
This is to refine my earlier observations, based on further enlightenment from Sandy McGuffog:

• (Just to clarify this) In no Leica cameras is an adjustment for lens geometric distortion applied to the raw data as delivered.
Doing so would be gravely problematical, owing to interpolation issues.​

• In the Leica M-series cameras, no opcodes to control correction of geometric distortion during raw development are included in the raw (DNG) files.

This is in large part due to the fact that when the overall plan of lens corrections for the M-series cameras was established, the DNG file format at that time did not accommodate opcodes.​

• In (for example) the Leica Q-series cameras, opcodes to control correction of geometric distortion during raw development are included in the raw (DNG) files (assuming that the lens is recognized by the camera and the user has not turned off lens recognition).

My understanding is that the way to provide correction of lens geometric distortion for the Leica M-series cameras (as for many other) during raw development in Photoshop/ACR or Lightroom is to rely on a lens correction profile (LCP) (perhaps constructed by the user if a suitable one is not available elsewhere, maybe included with one of those programs).

Best regards,

Doug
 
correcting color casts vs correcting distortion.

I would certainly trust Sandy's information, and supplement with some things that I have turned up from experimenting, mostly with Leicas using Phase One's Capture One software, and with Olympus's latest cameras.
The color cast probem bedevilled the M8 and M9, and was a source of many firmware updates. In the M8 firmware, which was not encrypted, you could read large tables in which the corrections for color shifts were placed. These are used when writing out the compressed DNG files. The problem of color casts is known to occur in digital backs from Phase One and others when used with wide angle lenses. A procedure called LensCastCorrection, involving shooting through a white diffuser and saving the image so that a correction can be applied to subsequent shots with the same lens, aperture, and focal distance is provided in Capture One for this problem. Sandy's CornerFix program does this for the rest of us, fixing vignetting as well as color shifts.

Barrel/pincushion distortion comes next. In classic Zeiss and Leica lenses (probably CaNikon's best as well), this rarely exceeds 1-2%, so it is hardly noticeable, but in the recent wave of mirrorless EVF cameras, it seems very common to simplify the lens cost and construction by leaving this correction to software. An example is the very highly regarded Panasonic/Leica 25mm Sumilux which if left uncorrected seems to have about 7-10% barrel distortion. But the Exif somewhere contains instructions on the amount of correction needed. In Capture One you see this explicitly. Open the DNG file in the Crop tool. A black band at the edge shows the area in which some distortion has been removed, in case you want to start your crop by leaving this out. A lens profile (there are about 20 of them for m43 lenses) is set by default to take this all out, leaving a pincushioned edge of the corrected frame, which must be cropped. You can reduce of eliminate the correction if you wish, getting more pixels in the image, and possibly better detail resolution in the corners and sides.

scott
 

Doug Kerr

Well-known member
Hi, Scott,

Thanks you for this valuable addition to our knowledge of this matter.

I would certainly trust Sandy's information, and supplement with some things that I have turned up from experimenting, mostly with Leicas using Phase One's Capture One software, and with Olympus's latest cameras.
The color cast probem bedevilled the M8 and M9, and was a source of many firmware updates. In the M8 firmware, which was not encrypted, you could read large tables in which the corrections for color shifts were placed. These are used when writing out the compressed DNG files. The problem of color casts is known to occur in digital backs from Phase One and others when used with wide angle lenses. A procedure called LensCastCorrection, involving shooting through a white diffuser and saving the image so that a correction can be applied to subsequent shots with the same lens, aperture, and focal distance is provided in Capture One for this problem.

Aha!

Sandy's CornerFix program does this for the rest of us, fixing vignetting as well as color shifts.

Barrel/pincushion distortion comes next. In classic Zeiss and Leica lenses (probably CaNikon's best as well), this rarely exceeds 1-2%, so it is hardly noticeable, but in the recent wave of mirrorless EVF cameras, it seems very common to simplify the lens cost and construction by leaving this correction to software. An example is the very highly regarded Panasonic/Leica 25mm Sumilux which if left uncorrected seems to have about 7-10% barrel distortion. But the Exif somewhere contains instructions on the amount of correction needed.

Are we sure this is in the Exif metadata (as distinct from, for example, by way of opcodes or something in the DNG file proper - I assume we are speaking of cameras in which the raw data comes in a DNG file)?

In Capture One you see this explicitly. Open the DNG file in the Crop tool. A black band at the edge shows the area in which some distortion has been removed, in case you want to start your crop by leaving this out. A lens profile (there are about 20 of them for m43 lenses) is set by default to take this all out, leaving a pincushioned edge of the corrected frame, which must be cropped. You can reduce of eliminate the correction if you wish, getting more pixels in the image, and possibly better detail resolution in the corners and sides.

Very interesting. Thanks again for this insight.

Best regards,

Doug
 

Doug Kerr

Well-known member
Hi, Scott,

The closest I have to a Leica camera is my Panasonic DMC-FZ1000. Its permanent lens has a really large (some would say revolting) focal length range - 25-400 mm ff35 equivalent.

If I open a raw file from this camera (not a DNG file - rather an RW2 file) in a raw developer that does not "know" this camera (except for enough to read its raw files), especially for shots taken at the "wide" end of the focal length range, we can see the rather severe geometric distortion.

But if I open the raw file in Silkypix Developer Studio, the "official" raw developer for this camera (although I have the "general use" version, for which this camera is listed as "supported"), I see an image essentially free of geometric distortion. I believe that this is done per tables that are part of the application, "called up" based on the identity of the camera (and thus by implication its lens) that is indeed carried in the Exif metadata.

I don't think I have the option to decline this operation (but I am not sure).

Best regards,

Doug
 

Doug Kerr

Well-known member
Nothing really new or surprising here, but just to complete the thought . . .

Here we see a raw file from my Panasonic DMC-FZ1000 opened in RawTherapee (this is a screen shot of the preview image), with no lens distortion correction profile invoked:

FZ1000_raw_via_Raw_Therapee-S600.jpg

This shot was taken with the lens at minimum focal length ("full wide-angle"). We see the ample geometric distortion. (Sorry I didn't have a grid chart or a wall full of bricks to shoot, but you can get the idea from this shot of part of my office.)

Here see the same file opened in Silkypix Developer Studio (again a screen shot of the preview image), with the "library" lens corrections for this camera applied:

FZ1000_raw_via_Silkypix-S600.jpg

The manual for Silkypix intimates that one can disable these corrections, but the explanation is confusing (the manual is in Japlish, to some extent) and I haven't yet be able to do that.

Best regards,

Doug
 
Top