Tried HDR Algorithms of OpenCV. Since the algorithm takes pretty much time. I tried few alternative steps as follows.

Took sample images from: HDR Images

1. Divided the image into four equal regions as Top Left and Right, Bottom Left and Right
2. Estimated the brighter region and the darker region from the Highly exposed image by taking average of the regions respectively
3. Replaced the brighter region with the average of Low and Mid exposed image.
4. Replaced the darker region with the average of High and Mid exposed image.
5. Then merged the images back into a single image.

Can someone suggest how to compensate the difference in them
Tried Exposure Compensator of OpenCV but does not get expected result.

The result image looks like: HDR Image


Here is one idea: Merge the HDR images per-pixel using known thresholds for saturation etc. The final image will have pixel values above 256.

Apply a CLAHE (Contrast Limited Adaptive Histogram Equalization, its in OpenCV) to get the final image.

Often just doing the later will make your images look good.

  • $\begingroup$ Thanks @Mikhail.. That was a nice option and it worked out the case. Does chossing the clip limit has any predefined ways..? $\endgroup$ Oct 14 '15 at 5:37

The effect is similar to having a gain which is different in the top-left quarter, and you need to somehow smoothen the discontinuity.

You can estimate the relative gain on both sides of the discontinuity by measuring the average luminance in small regions facing each other. [Where luminance values are saturated (>255), you can't measure the relative gain, ignore those areas.]

Now you probably want to keep parts of the image far from the discontinuity to look like they do now, meaning with a unit gain.

So to define the gain correction, you can consider a smooth function that equals one in the top-left corner and interpolates the measured function √G along the discontinuity. This looks like a diffusion equation problem. √G is chosen to distribute the discontinuity equally on both sides.

For the rest of the image, the gain correction will be 1/√G along the discontinuity and tend to 1 elsewhere.

In the end, the gain correction field will look like

enter image description here


I think the way to go is to rethink your approach in merging these images. I believe you already tried tonemapping and/or exposure fusion in opencv.

What you need is a some type of mapping function. Ex. for each pixel location Vout = Vin / ((n * 255)+1) where n is the number images and 255 is the max possible value that a pixel can get in an image. Vin is the total pixel value for the specific pixel location (sum of all the values of a pixel location in each image). Vout is the value for the specific pixel location for the resulting image.

You can find a nice list of tonemapping approaches in here

If you want to continue with your old approach, there is not much answer where you should write your own normalization function.

One idea that comes to my mind is to get small kernels inside the regions and find their average illumination relationships and try to preserve them after you merge them.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.