Thursday, 15 March 2012

First attempt at determining what the Nikon D40 anti-aliasing (AA) filter does to your image

Update: Please read follow-up article to this one.

It would appear that the same question pops up every time a new higher resolution sensor is announced: "Will my lenses be sharp enough for an X megapixel sensor?"

I was curious to see exactly what happens when the lens is much sharper than the sensor, so I set up an experiment. The idea is to select a sharp lens using a D7000 body, and then evaluate the performance of the lens on a lower resolution body, a D40 in this case. A by-product of this experiment will be a pretty good idea of what the anti-aliasing (AA) filter (also called the low pass filter) on the D40 does to the image.

First, I took my sharpest lens, a Sigma 17-50 mm f/2.8. At 35 mm f/5, this lens can resolve more than 60 line pairs per mm in the centre, which is a bit better than the Nikkor 35 mm f/1.8 prime (about 57 lp/mm in the centre). It is possible that this lens is even sharper than that, but as you will see, the D7000 sensor may be the limiting factor.

To construct a high quality, high-contrast straight edge I took a normal razor blade (2-sided variety), and blackened it with candle soot. The blade was mounted on a sheet of white paper (high quality, not normal copier paper). The camera was positioned at a distance of about 1.4 m from the target, to ensure we are in the "sweet spot" of lens performance. A flash was used to ensure maximum contrast. Here is what the raw Bayer image data from the D7000 looks like (upscaled for display)
On the D7000, focus was performed with LiveView, and the sharpest shot of a sequence was selected. On the D40, I started with AF, and then bracketed focus manually, again selecting the sharpest shot from the sequence. 

Before we look at the details of the curve shapes, first some justification: I do not have the equipment to measure if the Sigma lens is diffraction limited, but if I can measure an MTF50 of 60 lp/mm on a D7000 sensor, then I should be safe on the D40 sensor, which has a theoretical Nyquist limit of 64 lp/mm. I have thus assumed that lens resolution is not the limiting factor for the D40, i.e., that the MTF curve we measure is really the D40 AA filter MTF curve.

The razor edge was then processed with MTF Mapper to extract MTF curves of the green photosites (i.e., no demosaicing was applied, no interpolation, just the raw green photosite data). Plotting the MTF curves in cycles per pixel gives us the following:

The red curve (which looks like a straight line here) is the diffraction-limited MTF curve for the selected aperture (f/5), plotted against the scale of the D40 pixels (7.8 micron). The real diffraction-limit MTF is independent of pixel size, but because the plots are in terms of cycles per pixel, the diffraction curve would be "lower" (i.e., steeper slope) if we plotted it for the D7000 pixel pitch (not shown). The diffraction limit is the absolute physical upper resolution limit imposed by the lens aperture.

The orange curve is the measured MTF curve for the D40. The dashed blue curve is the MTF curve of a Gaussian blur kernel with the same MTF50 value as the D40 curve, i.e., 0.294 cycles/pixel. The D40 curve is quite close to the Gaussian, which would mean that sharpening the D40 image with an inverse Gaussian, i.e., Richardson-Lucy (RL) deconvolution such as implemented in RawTherapee, is a really good match for the D40.

The black curve is the measured MTF curve for the D7000. This curve is quite different from the D40 curve. There are two possible explanations: either the D7000 AA filter has a different MTF curve shape (compared to D40), or the lens is not quite sharp enough to reveal the sensor AA filter MTF completely. I suspect the latter is more likely. At any rate, the interesting thing here is that the contrast is much lower than the D40 at around 0.15 cycles per pixel. In other words, per-pixel microcontrast may appear lower than the D40, but this will probably be rather subtle because the MTF50 values are so close, which can be observed at around 0.29 cycles per pixel.

That wraps it up for comparing per-pixel sharpness (which would be analogous to comparing 100% crops for sharpness). What about real-world sharpness? We can plot the same data on a line pairs per mm scale:

Here we can see that the D7000 performs much better than the D40. The measured MTF50 values are 60.47 lp/mm for the D7000, vs 37.64 for the D40. The D7000 thus captures images that are sharper by a factor of 1.61 than the D40. Now for the punchline: the linear increase in resolution going from the D40 to the D7000 is 1.649 (7.8 micron pixels vs 4.73 micron pixels). From this, I deduce that the Sigma 17-50 mm f/2.8 lens is sharper than the D7000 sensor. This is of course only in the centre of the lens. This is further corroborated by Sigma's published MTF curve for this lens. They claim roughly 0.9 contrast at 30 lp/mm, I measured 0.77 on the D7000, and 0.63 on the D40 at 30 lp/mm.

The other feature that I would like to point out is the contrast at 40 lp/mm. The D7000 obtains a contrast value of 0.68, D40 only 0.46, thus the D7000 manages to pull out about 49% more contrast at that resolution. This will produce a lot more "pop" at 6x9 print scales.

Lastly, my take on the Nikon AA filters: It would appear that the D40 AA filter has an MTF50 of around 0.3 cycles per pixel (allowing for experimental error), which produces a blur that is very close in shape to a Gaussian. This seems to put the effective resolution of the D40 at about 60% of the resolution implied by the pixel pitch, which is lower than the 70% figure often quoted for sensors with Bayer and AA filters. The D7000 seems to be heading in the same direction, i.e., an MTF50 of 0.3 cycles/pixel, or a peak resolution of about 63.4 lp/mm.

Norman Koren stated that 0.33 cycles per pixel is "pretty decent for digital cameras" ( He must have been referring to Canon bodies 

... Some time passes ....
Ok, so I speculated that the D40 MTF curve looks like a Gaussian, and that the D40 AA filter may have an MTF50 value of 0.3. After thinking about this a bit, I had another idea: If the AA filter MTF is a Gaussian, and we assume that the lens is diffraction limited (which is likely for the Sigma 17-50 mm, as explained in above), then we should obtain the diffraction limit MTF if we deconvolve the measured D40 MTF curve with the best-fitting Gaussian MTF.

Since that paragraph was unhelpfully technical, let me try to explain in a more straightforward way: With digital SLRs, you have to sharpen the image to counteract the effects of the AA filter. So if the AA filter function is a Gaussian (i.e., shaped like the blue dashed curve in the plots in this post), then optimal sharpening would completely "undo" the effect of the AA filter. If our lens is diffraction limited, we expect to measure the diffraction-limit MTF (the dashed red curve in the plots), but obviously our sensor will "blur" that curve. So if we use a Gaussian MTF to "sharpen" our image, and the result is the diffraction curve, then our lens must have been diffraction limited.

The following plot illustrates this:

From this plot it would appear that the D40 AA filter is closer to a Gaussian with an MTF50 of 0.33, or that the Sigma lens is almost, but not quite, diffraction limited.

This would put the "optimal" radius for an unsharp mask (or standard deviation for RL deconvolution) at 0.57 pixels for the D40. In other words, this amount of sharpening would not introduce "oversharpening" artifacts in the sharpest part of the image. Other parts may require more sharpening (larger radius or standard deviation), but then you run the risk of oversharpening the sharp parts.

One more thing: above I measured the MTF50 to be 0.293 for the D40, and speculated that the AA filter MTF can be approximated by a Gaussian with an MTF50 of 0.3, and here we see that a Gaussian with MTF50 of 0.33 appears to be a better fit. Why the difference? Well, a slight defocus blur will also be approximately Gaussian in shape, i.e., a small amount of defocus blur will likely be present in all MTF measurements. This defocus blur will lower the measured MTF, hence requiring a more "sharpening" using the deconvolution method above.

Update: Please read follow-up article to this one.

No comments:

Post a Comment