Skip to content

codehack9991/HDR-image-generation-using-CNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HDR-reconstruction-using-CNN

Create HDR images from LDR inputs:

| (left) LDR input | (middle) Exposures taken from the predicted HDR | (right) Tone mapped HDR |



Prerequisites

Requires the PyTorch library along with OpenCV.

First follow the instructions for installing PyTorch.

To install OpenCV use:

conda install opencv -c menpo

Usage

The script accepts an LDR image as input, and creates an HDR Image prediction (.hdr file).

python expand.py  ldr_input.jpg

Can also do batch processing

python expand.py  *.jpg

To put results in a separate directory:

python expand.py  *.jpg --out results/

Results can be resized and filenames can be tagged:

python expand.py test.jpg --resize True --height 960 --width 540 --tag my-tag

If a GPU is available and Pytorch detects it then the conversion will happen on the GPU. To force CPU usage (slower) set --use_gpu False.

The network operates on patches to limit memory usage when expanding high resolution images. The flag --patch_size adjusts the size.

The resulting HDR Image can be tone mapped using the TMOs provided by OpenCV, or using the exposure operator.

python expand.py  test.jpg --tone_map reinhard

Testing on video

Use --video True (along with a tone mapper --tone_map) to test video conversion.

WARNING This is completely new and experimental. Very slow and memory consuming! Should only test short low-res clips. The model is not designed for videos thus flickering occurs which is reduced in the code by smoothing luminance percentile curves.

In the following example, on the left is the LDR video input and on the right is the (reinhard) tone mapped prediction.

Any tips to improve this are welcome!


Viewing HDR Images

There is a very easy to use online viewer at openhdr.org which also has tone mapping functionalities!


Releases

No releases published

Packages

No packages published

Languages