mitigating lens diffraction with diffuse & sharpen

I have been reading a bit of theory about correcting lens diffraction, especially on how given lens characteristics, a deconvolution could be used to remove it. But, unfortunately, manufacturers do not share this data. So I tried to do it by eyeballing with diffuse and sharpen.

I tried on my Canon G7 X Mark II, maxing out aperture at F11, to get the worst. The reasoning is that this is not a high-quality lens, so it is ideal for this kind of experiment. The target is a sketch drawn with a felt-tip pen.

This is what it looks like without correction (just lens correction and CA, and black level adjusted to emphasize the problem, 100% crop):

Below is the corrected version — 5 iterations of -10% 4th order speed, +2% 4th order anisotropy. I experimented with all orders, and found that this works best for my purposes. But suggestions for improvements would be welcome. The idea is not to optically sharpen the edges with extra local contrast, just to make it neutral.

If this works, I could

  1. print a nicer-looking grid on proper photo paper with more even blacks,
  2. do this exercise and store presents for all my lenses for all apertures I usually use, and just apply them as a starting point. I found that diffraction is harder to correct on actual images (I tend to optically overcorrect).

IMG_4622.CR2 (25.4 MB)
IMG_4622.CR2.xmp (7.8 KB)

So… comments, suggestions, and improvements are welcome. All images are licensed CC BY-NC-SA 4.0.

3 Likes

I wonder if it would be possible to profile a lens, in a manner similar to Lensfun and noise profiles. Seems like it could be an interesting project for the mathematically inclined.

Possibly, but two caveats:

  1. this is not a correction in the mathematical sense, just a stopgap approximating what would need to be done.
  2. at least for compacts, there is a huge amount of variation in lenses for the same model.

I am curious if anyone ends up using the other orders. I am surprised that in the end the 4th gave the best results.

From the manual, I gather that the 4th order is only working on and with high-frequency data, which is just where the diffraction artifacts occur. So that’s perhaps not all that surprising.

True deconvolution has two problems:

  • getting the kernel correct is not trivial, and deconvolution tends to be slow
  • worse, with the common algorithms it’s very easy to get particularly nasty artifacts (FFT giving “ringing” artifacts), which are inherent in the algorithm.
1 Like

@Tamas_Papp I am not answering your question, but just saying you have posted a really nice example of why the diffuse or sharpen module is so great to use. I personally use AP’s pre-sets for lens deblur as my sharpening method in conjunction with the demosaicing sharpening pre-set. I feel this module gives true sharpening to an image, whereas the traditional methods employing the unsharp mask technique are just creating an optical illusion with artefacts.

1 Like

My only thought at this point, apart from “sounds good!” is that some lens show different optical properties at close focus distances - not sure if that would change diffraction. Just thinking that maybe a larger target further away may be needed…

My (perhaps naive) understanding is that diffraction happens at the lens opening, and then light just travels to the sensor, making an Airy disc. Focal length just cancels out. Focal plane distance should have no first-order effect.

So, in theory, I could just calibrate my lenses at different apertures, and be done with it. Also, in theory it is fairly independent of lenses, even the very best lenses cannot (and thus do not) compensate for diffraction optically. If this is correct, a simple set of presets could be shared, for each sensor size and aperture.

But I am not an expert at this, comments welcome.

What I am especially curious about is whether diffuse & sharpen just deals with the central Airy disc, and I just can’t see the rings because in comparison they are insignificant, or if it could deal with everything.

2 Likes