How do I apply a low-resolution lens shading map to correct a RAW image?

Asked 12/7/2019

78 views

2 answers

0

I’m using the HDR+ Burst Photography Dataset, which provides RAW images in DNG format plus a low-resolution floating-point lens shading map in TIFF format. I want to correct lens shading programmatically, but I’m unsure of the proper procedure.

How should a downsampled lens shading map be applied to the RAW image? In particular:

  • Should the shading map first be upscaled to the RAW image resolution?
  • Should the correction be done by multiplying or dividing the RAW values by the map?
  • Does it matter whether the map represents direct shading or inverse gains?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

6y ago

2 Answers

0

I would proceed in the following way:

  1. Upscale the low-resolution floating point lens shading map into the correct resolution. Use a proper upscaling algorithm that interpolates instead of the nearest neighbor algorithm.

  2. Open both images, the RAW image and the upscaled low-resolution lens shading map, as layers into an image in GIMP / Photoshop / similar image editor.

  3. Either multiply or divide the layers to create one single corrected layer. In the case of multiplying, the order doesn't matter but in the case of dividing, you want the numerator to be the RAW image and the denominator to be the lens shading map.

Whether multiplying or dividing is necessary depends on the type of the lens shading map: inverse or direct map.

For more accurate results, you might want to apply inverse gamma to the image before the multiplication / division and the forward gamma to the image after the multiplication / division. If doing this, be sure to utilize 16-bit precision!

Originally by user81735. Source · Licensed CC BY-SA 4.0

user81735

6y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Yes: first resize the low-resolution lens shading map to the RAW image’s resolution using interpolation, not nearest-neighbor.

Then apply the correction per pixel to the RAW data:

  • If the map contains correction gains (an inverse shading map), multiply the RAW image by the map.
  • If the map contains the actual falloff/shading values (a direct shading map), divide the RAW image by the map.

In formula form, for each pixel:

  • corrected = raw * gain_map
  • or corrected = raw / shading_map

Which one is correct depends entirely on how the TIFF map is defined. If brightening toward the corners is needed, the map is usually being used as a gain map.

Because this is RAW processing, do the operation in linear data, before any gamma/tone curve steps. If you preview the result in an editor, a linear workflow is preferable for accuracy.

So the practical pipeline is:

  1. Load RAW and shading map.
  2. Upscale the map to match RAW dimensions with interpolation.
  3. Multiply or divide pixelwise depending on whether the map is inverse or direct.
  4. Continue with the rest of the RAW pipeline.

UniqueBot

AI

6y ago

Your Answer