Pages: [1]   Go Down

Author Topic: Didactical R implementation of an optimum HDR fusion  (Read 978 times)

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Didactical R implementation of an optimum HDR fusion
« on: July 20, 2018, 04:45:08 pm »

For didactical purposes (both in practising with R and to try some new strategies), I have written some R code which implements and optimum HDR fusion of 2 captures shot 4EV apart over a high dynamic range scene (12 stops).

IMAGE HDR FUSION WITH R (Google translation up right)

This was the scene:




Ignoring the RAW metadata (nominally 4EV apart), we calculate a much more precise relative exposure ratio which happens to be 15,69 rather than 16 (4EV).




I have also plotted the RGB levels participating in the calculation, all belonging to the mid tones as expected. Colours mean that for some pixels not all RGB values were used, only those that fell between some min/max thresholds. Over 20% of the entire image information was used for the calculation.




Accurately calculating the relative exposure is necessary to perform an exposure correction down on the +4EV shot to match its overall exposure so that a seamless composite can be build taking some RGB values from one shot or the other, without any progressive blending area. Even for a given pixel, some RGB channel may come from one shot while the other two channels could come from the other, and it worked; I had never tried such a fine pixel selection.

This was the fusion map: black pixels mean information is taken from the most exposed shot, white pixels are taken from the low exposure shot, and again colours mean areas with a mixed information source:




I encourage you to download the fusionmapeotonos.tif file to check which information comes from which source RAW file. A couple of curves are included for final tone mapping, although perfect tone mapping was not the main goal of the exercise.


Regards


« Last Edit: July 20, 2018, 04:55:02 pm by Guillermo Luijk »
Logged

kirkt

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 604
Re: Didactical R implementation of an optimum HDR fusion
« Reply #1 on: July 21, 2018, 10:20:29 am »

For didactical purposes ...

I have also plotted the RGB levels participating in the calculation, all belonging to the mid tones as expected. Colours mean that for some pixels not all RGB values were used, only those that fell between some min/max thresholds. Over 20% of the entire image information was used for the calculation.

....

Even for a given pixel, some RGB channel may come from one shot while the other two channels could come from the other, and it worked; I had never tried such a fine pixel selection.

This was the fusion map: black pixels mean information is taken from the most exposed shot, white pixels are taken from the low exposure shot, and again colours mean areas with a mixed information source...



This is very interesting Guillermo.  What causes the algorithm to decide to split RGB channels over the two exposures for a single pixel? 

I miss seeing that test image everywhere!

Kirk
Logged

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Re: Didactical R implementation of an optimum HDR fusion
« Reply #2 on: July 21, 2018, 12:06:30 pm »

Hi Kirk! think of the following two pixels (linear 16-bit values):

Px1: RGB=(5000, 2000, 1000)
Px2: RGB=(65535, 32000, 16000)

The 32000 and 16000 values from Px2 can be used to build the HDR composite, but the 65535 is clipped. So we'd take R from Px1 and GB from Px2:

HDR: RGB=(5000, 32000/16, 16000/16)

In a real application (like Zero Noise) I would not mix RGB values since the advantage is negligible vs increased ghosting and sharpness issues, but I wanted to try it and find out if it worked in practice. Moreover the R code is simpler working RGB values individually.

In fact there is some ghosting in the form of false colours created in the moving leaves.

Regards
« Last Edit: July 21, 2018, 04:59:46 pm by Guillermo Luijk »
Logged

kirkt

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 604
Re: Didactical R implementation of an optimum HDR fusion
« Reply #3 on: July 21, 2018, 07:38:39 pm »

Yes, makes sense - which is one reason why you need to make sure you calculate exposure diff accurately as you articulate in your original post.

I'm glad to see you are still experimenting with your Zero Noise concept!

kirk
Logged
Pages: [1]   Go Up