# EasyHDRFusion

| Support            | ![](assets/images/sample_programs/applies_to/cpp.svg) ![](assets/images/sample_programs/applies_to/cs.svg) ![](assets/images/sample_programs/applies_to/qt.svg)   |
|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Required licenses  | **EasyImage**                                                                                                                                                     |
| Recommended images | Any image from the folder `Sample Images/EasyImage/HDR`                                                                                                           |
| Location           | `Image Processing/EasyHDRFusion`                                                                                                                                  |

## Purpose

This sample program demonstrates how to:

- Perform an HDR Fusion on a specific set of images.

The process steps are:

1. Load a set of color images.
2. (Optionally) Set the related exposure time for each image.
3. (Optionally) Set an alternative merger algorithm or an alternative tone-mapper algorithm.
4. Perform the HDR Fusion.

![](assets/images/sample_programs/image_processing-hdrfusion.webp)

## Code highlights

* Perform the HDR Fusion from a set of images.
  ```c++
  std::vector<EImageC24> imgs; // previously loaded, all images have the same size
  std::vector<float> exposureTimes; // previously loaded

  EImageC24 output(imgs.back()); // its dimension must previously set, same size as the input images

  EHDRFusion fusion; // by default, the fuser uses a merger that uses the Mertens algorithm, and a linear tone-mapper
  ```

1. Set the related exposure time for each image.

#### ATTENTION
If a merger that is not of type `Mertens` or a tone-mapper is used, the related exposure time but be set for each image:

```none
```c++
std::vector<float> times = {
  1.0f / 0.03125f,
  1.0f / 0.0625f,
  1.0f / 0.125f, 1.0f / 0.25f,
  1.0f / 0.5f,  1.0f / 1.0f,
  1.0f / 2.0f,
  1.0f / 4.0f,
  1.0f / 8.0f,
  1.0f / 16.0f,
  1.0f / 32.0f,
  1.0f / 64.0f,
  1.0f / 128.0f,
  1.0f / 256.0f,
  1.0f / 512.0f,
  1.0f / 1024.0f}; // must have the same number of elements as the input `imgs`
```
```

1. Set an alternative merger algorithm or an alternative tone-mapper algorithm.

The type of merger or tone-mapper can be set at the creation of the creation of the `HDRFusion` object:

```none
```c++
EDebevecMergerParameters mergerParams; // can also be ERobertsonMergerParameters or EMertensMergerParameters
EReinhardToneMapperParameters toneMapperParams; // can also be EDragoToneMapperParameters or ELinearToneMapperParameters or EMantiukToneMapperParameters

EHDRFusion fusion(mergerParams, toneMapperParams);
```
```

1. Perform the HDR Fusion.
   ```c++
   EImageC24 output;
   fusion.Fuse(imgs, output); // if using Mertens merger algorithm
   // OR
   fusion.Fuse(imgs, output, times); // if not using Mertens merger algorithm
   ```
