Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

HDR fusion (Mertens) gives different results in Python Vs. C++

When I run the HDR Mertens exposure fusion in Python I get weird colors artifact, that I don't get when I run the exact same function in c++. (I just run the HDR Tutorial)

Seems to me like some problem with the data types, but I tried every option and nothing works. Am I doing something wrong?

I'm running Python 3.5 64-bit with OpenCV 3.0.0.

The exposures images were taken from Wikipedia: 1/30 sec, 1/4 sec, 2.5 sec, 15 sec.

The Python code:

import cv2
import numpy as np

img_fn = ["640px-StLouisArchMultExpEV+4.09.jpg",
          "640px-StLouisArchMultExpEV+1.51.jpg",
          "640px-StLouisArchMultExpEV-1.82.jpg",
          "640px-StLouisArchMultExpEV-4.72.jpg"]
img_list = [cv2.imread(fn) for fn in img_fn]

# Exposure fusion using Mertens
mergeMertens = cv2.createMergeMertens()
resFusion = mergeMertens.process(img_list)

# Convert datatype to 8-bit and save
resFusion_8bit = np.uint8(resFusion*255)
cv2.imwrite("fusion.png", resFusion_8bit)

The result I get in Python:

image description

The result I get in C++:

image description

HDR fusion (Mertens) gives different results in Python Vs. C++

When I run the HDR Mertens exposure fusion in Python I get weird colors artifact, that I don't get when I run the exact same function in c++. (I just run the HDR Tutorial)

Seems to me like some problem with the data types, but I tried every option and nothing works. Am I doing something wrong?

I'm running Python 3.5 64-bit with OpenCV 3.0.0.

The exposures images were taken from Wikipedia: 1/30 sec, 1/4 sec, 2.5 sec, 15 sec.

The Python code:

import cv2
import numpy as np

img_fn = ["640px-StLouisArchMultExpEV+4.09.jpg",
          "640px-StLouisArchMultExpEV+1.51.jpg",
          "640px-StLouisArchMultExpEV-1.82.jpg",
          "640px-StLouisArchMultExpEV-4.72.jpg"]
img_list = [cv2.imread(fn) for fn in img_fn]

# Exposure fusion using Mertens
mergeMertens = cv2.createMergeMertens()
resFusion = mergeMertens.process(img_list)

# Convert datatype to 8-bit and save
resFusion_8bit = np.uint8(resFusion*255)
cv2.imwrite("fusion.png", resFusion_8bit)

The result I get in Python:

image description

The result I get in C++:

image description