Question about the algorithm to manually merge stack based HDR

I’m trying to generate a HDR bayer photo from 3 12bit-bayer photos with -2EV, 0EV and 2EV exposure settings.

The problem is the overexposed one will always bring pinkish color to the merged photo.


(The left one is merged with the overexposed image, the right one is without the overexposed image)


The exposure time of these three are:

  • 1/131s for -2EV
  • 1/121s for 0EV
  • 1/60s for +2EV

Let’s take three pixels for example, they are in the same position in the bayer photos:

> a = [372 * 131, 926 * 131, 543 * 131]   // 3 pixels R,G1,B from frame -2EV / exposure_time

[ 48732, 121306, 71133 ]

> b = [1494 * 121, 3515 * 121, 2019 * 121]    // 3 pixels R,G1,B from frame 0EV / exposure_time

[ 180774, 425315, 244299 ]

> c = [3567 * 60, 3514 * 60, 3492 * 60]   // 3 pixels R,G1,B from frame +2EV / exposure_time

[ 214020, 210840, 209520 ]

I’ve tried a lot of different types of weight functions, none of them can avoid the pinkish effect in highlight. No matter which kind of weight function I use, as long as I bring pixels from c into the HDR, I will get a pinkish result.

If I only use a + b, then everything is good except I cannot get the better dark area pixels from c.

So how to merge them properly?

The pink is classic whitebalance-shifted saturation pileup on the right end. What’s your workflow, straight from raw? If so, you might consider raw-developing the over-exposed one to apply highlight reconstruction to it, then save it to a high-bit TIFF for the merge…

2 Likes

straight from raw?

Yes

Thank you for your advice. I’ll do the research on the highlight reconstruction.

1 Like

Software already exists to do this, do you really want to process the images manually / using your own software (e.g. to learn)?

1 Like

@kofa do you mind me asking what is your favourite HDR merging program? I have become disillusioned with most of the software out there doing this.

1 Like

I hardly ever use one, at least not with my Nikon DSLR.

When I do (usually with an exposure sequence from my phone, created using Open Camera or Hedge Cam), HdrMerge is quick, but its assignment algorithm is not so great. It works on raw files, creates a DNG, which can then be processed normally. If there isn’t much movement, it performs OK.

Hugin can also align and merge images, I use it with linear TIFF files (no tone mapping, just demosaic, lens corrections and white balance applied).

1 Like

I want to learn the key processing methods in a stack based HDR merging.

2 Likes

I wonder if learning about luminosity masks for HDR blending would be of any help to you. The images need to be aligned, but this method showed great promise when I tried it. Here are some very brief notes I made for my self using GIMP and JPG or Tiff files. I find Raw files less often need HDR treatment. This information is probably not much help so forgive the noise I am adding to your thread.

LMs in GIMP

  1. Load three exposures as layers dark, norm, light
  2. Put dark on top and create LMs by Script-Fu>Create new>Luminosity masks (note LMs create a stack of masks above the dark layer)
  3. Select a light mask to retain highlights
  4. Layer>mask>add to selection
  5. Activate original dark layer, create layer mask to selection
  6. Get rid of selection
  7. Experiment with which masks to deactivate to get desired effect.
  8. Repeat the steps using the normal layer to lighten the shadows by selecting a dark mask invert?
2 Likes

It’s very inspiring and helpful, thank you.