Tuesday, October 13, 2009

Vignetting Correction Issues on the Leica M9

There's been a lot discussion on the Leica User Forum about problems with vignetting correction on the new M9. These have shown up in a number of different images, but the image below of a white diffuser shot with a coded Leica 18mm f/3.8, which should be entirely uniform edge to edge, shows the problem well:


18mm f/3.8 with "Auto" in-camera correction

Basically, there is a red tint on the side - mostly the left hand side - of the image despite, or perhaps because of, the in-camera correction. As CornerFix hasn't been able to correct some these images while it was usually able to correct M8 images with red corners, I've been trying to work out what the issue is, with the help of several people on the forum that have sent me images - Carl Bretteville, Eric Calderwood, Jonothan Slack, Tim Ashley and others - thanks to all of them!

Background

The background to this is that on any M-mount digital camera, you have a fundamental optical problem. On any digital camera you have to have an IR (infra red) filter to prevent color shifts due to IR contamination - all modern sensors are very sensitive to IR. However, because the M-mount has such a short lens to sensor distance, the light has to be at a considerable angle to reach the corners of the sensor. In turn that means that light that goes to the corners of the sensor passes through the IR filter at a sharp angle. That means that it passes through "more" of the filter, and reds get cut, resulting in cyan drift - blue corners. The M8 and M9 compensate for this by coding lenses, allowing the camera to boost reds (and greens, slightly) to compensate for the impact of the IR filter on visible light. CornerFix does the same thing, but as a post processor.

What's happening with the red edges above is that the cyan drift is somehow being over-compensated, red being boosted too much, and as a result you get red edges.

There are a few questions here - why exactly is this happening, what can be done about it, and most puzzling - why does this seem to happen on the left edge of images only?

The 18mm lens uncoded

To find what is happening with the in-camera correction, I did some analysis on the raw data in images shot of either a white diffuser or white walls. All of the images and charts in this post for a Leica 18mm f/3.8, but I've also looked at a number of other lenses, including a Zeiss 25mm, and some CV12's. All of the 18mm images are from Tim Ashley, btw - Tim shot these through a high-end diffuser, so the illumination is very even, which makes the charts clearer.

The first image is from the 18mm with lens detection disabled, so no lens specific in-camera correction. This is the image with the lens uncoded:


18mm f/3.8 with no in-camera correction

The chart below shows the the vignetting of the different colors (red, green1, green2, blue, because this is raw Bayer matrix data) across the horizontal center of the image, with the horizontal axis in pixels, and the vertical axis in stops of vignetting. The chart shows dots for pixels of the Bayer array, and best fit polynomials for each Bayer color to make things clearer :



18mm f/3.8 with no in-camera correction


You can tell a few things from this plot:
  1. The luminance vignetting (effectively the blue curve) is about 1.3 stops at the edges. Note that because this cut is across the center of the image, corner vignetting is more than you see here; if the cut was the diagonal, you would see over two stops.
  2. The chroma vignetting (the difference between the blue and red curves), the thing that gives the cyan corners, is about 0.2 of a stop. It's cyan because green is also impacted by the IR filter.
  3. Most important, the lens is somewhat asymmetrical - vignetting on the left is greater than on the right. Note that both the luma AND chroma vignetting are greater. This is probably caused by the optical center of the lens not being aligned with the optical center of the sensor. Note that some asymmetry exists in almost all lens; I've routinely seen similar (and greater) asymmetry in other lenses from Leica, as well as Zeiss and Nikon lenses.
To correct for vignetting, what we would want is:
  • To correct chroma vignetting only, we'd want the red, green and blue lines to coincide. What that would mean would be that there would still be "normal" luma vignetting, but no color drift.
  • To correct luma vignetting as well, we would want all the lines to be flat.
One thing to be aware of is that even on an uncoded lens the M9 may apply some degree of luma vignetting correction, although there's no way to tell for sure. However, this isn't relevant to our discussion here.

The 18mm with in-camera correction

The second chart shows what happens with the Auto lens detection (the corresponding actual image is the one at the start of this post):



18mm f/3.8 with "Auto" in-camera correction


What is shows is that on the right hand side, the correction of the color vignetting is near perfect (all the lines coincide), but on the left, the in-camera algorithm is over correcting red by about 0.1 of a stop. That's what gives the left edge of the actual image its red tint, so the red edge is not a figment of anyone's imagination. It's also interesting to note that Leica is not correcting very much at all of the luma vignetting.

Coding as a WATE at 16mm

It's also instructive to look at what happens if the code the 18mm as a 16mm WATE. This is the image you get:



18mm f/3.8 with WATE 16mm in-camera correction


The chart is as follows:


18mm f/3.8 with WATE 16mm in-camera correction

Two things are interesting here:
  • Although this image is technicaly not as well corrected as the correct 18mm "Auto" coding, the WATE coding looks better than the 18mm coding. The reason is that while the WATE coded version is less well corrected, it's not over corrected, and its the red edges and corners that make the 18mm correction look so bad.
  • The second thing to note is that, if you look closely at the left hand side of the chart, you'll see that the red and green curve actually cross. Although its difficult to see in the image, that actually results in sort of a rainbow effect, with the image alternating from cyan under correction to red over correction. This is because the shapes of the correction curves for the WATE and the 18mm are actually different. This is important because many Leica users tend to assume that that the difference between in-camera corrections between lenses is just the "strength" of the correction. That's not actually true; the entire shape of the curve can be different for different lenses. The result is that using an in-camera correction for a lens it wasn't designed for is more difficult that many assume. Given that the M9 needs considerably more correction than the M8 did, this is likely to be a significant issue for users that have become accustomed  to being able to use in-camera corrections for non-Leica lenses; that approach may no longer be nearly as effective.
So where does the asymmetry come from?

Bottom line is that I would say that what's happening here is that (as I had suggested in previous posts on the forum) asymmetry is going to be real problem for correcting cyan drift on the M9. It's not really clear what the root cause of the asymmetry is - there are a number of possibilities:
  1. Lens asymmetry. Asymmetry in the lens itself (simplistically, the mechanical and optical centers being different) is by far the most likely reason for what we're seeing, and is certainly a large part of the problem. However, that doesn't explain why all the over correction examples I've seen to date have been red on the left, not the right. You would expect that the direction of lens asymmetry would be random, not all in one direction. It is possible that this is some kind of a artifact of the ways lenses are calibrated in the factory, but it is strange, and the bias to the left wasn't apparent on M8s.
  2. Camera asymmetry. Inevitably, the sensor is not always exactly aligned with the mechanical center of the lens mount. If this was the case for the M9 as a matter of design, or due to some quirk of the manufacturing process, it would explain the left bias. However, sensor to lens mount alignment is usually trivially easy to get right compared to the optical alignment of lenses, and in order to account for the degree of left bias, a substantial asymmetry would be required. It is thus unlikely that camera asymmetry would account for the variation.
  3. Asymmetry in the in-camera correction process. I did perform a test by subtracting the corrected image from the uncorrected image, which gives an estimate of the Leica correction curve, as shown below. Surprisingly, the Leica in-camera correction does appear to be very slightly asymmetric, but in the wrong direction! However, it is only asymmetric to a very small extent, and given that the measurement, made by subtracting two different images, is inherently imprecise, it's likely that the correction is actually symmetrical. The "lines of dots", btw, are as result of compression.

Leica in-camera corrections for 18mm f/3.8 (see text)


Can CornerFix fix this?

In a word, no, not using the current version. The current version of CornerFix will do as well as the Leica in-camera corrections, but no better.

The reason for this is that the current version of CornerFix is explicitly designed to correct symmetric vignetting. Substantial change - already underway - is going to be required to allow it correct for the kind of asymmetry found here.

<UPDATE: The latest versions of CornerFix do correct the problem>


Conclusion

As a results of these tests, it is fairly clear that the "red edges" are as a result of variations in centering between the lens, the sensor, and the in-camera correction algorithm. This issue showed itself on the M8, but wasn't significant enough to cause major problems. However, on the M9 this clearly is able to cause visible image degradation. Based on the available evidence, we can't say what the root cause of this de-centering is. However, we can reach a number of conclusions:

  1. What I think that Leica probably need to do to fix the immediate in-camera correction problem with the 18mm is just to tune back the 18mm's red correction by 0.1 of a stop, or some value based on production variation with the lens. That will leave the right a bit under compensated, but under compensation is a lot less visually disturbing than over compensation, as shown by the WATE example above.
  2. CornerFix will need to be enhanced to be able to deal with asymmetric vignetting - as mentioned above, I've started that process.

There are still a few things I don't understand however. The major one is why its always "red on the left", as discussed above. The second one is to what extent this issue varies with aperture setting. There is evidence that it does change significantly, getting worse with increasing aperture, but I don't as yet have enough data across enough lenses to be sure. The variation might be with either real aperture, because the aperture blades themselves are contributing to the vignetting, or at least changing the effective optical center of the lens, or with the M9's estimated aperture, because the correction that Leica are applying varies with estimated aperture. Although, supposedly Stephan Daniel said in an interview that the M9 correction is not variable with aperture.

3 comments:

Carsten said...

Sandy, might it be that Leica used a decentered lens to generate the original data used in the correction?

Carsten

Sandy said...

Carsten,

It's possible - if so, it would be pretty sloppy work by Leica.

Sandy

Alan said...

That looks like an awful lot of vignetting to me. Corrected or not.