# Using Flat Images to Improve Photometric Stereo

The code shows how to use flat images to improve photometric stereo’s results.

## C++

```cpp
#include <eVision/Easy3D/EPhotometricStereoImager.h>
```

```cpp
using namespace eVision;
using namespace eVision::Easy3D;

EPhotometricStereoImager photometricStereo;
// calibrate imager or sets its angles (Todo)

// Load flat images in the same order than the calibration images/angles (Todo)

std::vector<EROIBW8> flatROIs;
// Set the flat images ROIs (Todo)

// Configure flat images, this could optionally be done with a dark image as well
photometricStereo.ConfigureNonUniformLightingCorrection(flatROIs);

std::vector<EROIBW8> objectROIs;
// Set the object ROIs (Todo)

// Perform one or more computations, each will use the flat images (Todo)
photometricStereo.Compute(objectROIs);

// Optional: non uniform lighting correction could be disabled or (re-)enabled
// using SetEnableNonUniformLightingCorrection
```

## C#

```cs
using eVision;
using eVision.Easy3D;
```

```cs
EPhotometricStereoImager photometricStereo = new EPhotometricStereoImager();
// calibrate imager or sets its angles (Todo)

// Load flat images in the same order than the calibration images/angles (Todo)

EROIBW8[] flatROIs = new EROIBW8[4];
// Set the flat images ROIs (Todo)

// Configure flat images, this could optionally be done with a dark image as well
photometricStereo.ConfigureNonUniformLightingCorrection(flatROIs);

EROIBW8[] objectROIs = new EROIBW8[4];
// Set the object ROIs (Todo)

// Perform one or more computations, each will use the flat images (Todo)
photometricStereo.Compute(objectROIs);

// Optional: non uniform lighting correction could be disabled or (re-)enabled
// using SetEnableNonUniformLightingCorrection
```

## Python

```py
import eVision
from eVision import Easy3D
photometric_stereo = Easy3D.EPhotometricStereoImager()
# calibrate imager or sets its angles (Todo)

# Load flat images in the same order than the calibration images/angles (Todo)

flat_rois: list[eVision.EROIBW8 | None] = [eVision.EROIBW8(), eVision.EROIBW8(),
    eVision.EROIBW8(), eVision.EROIBW8()]
# Set the flat images ROIs (Todo)

# Configure flat images, this could optionally be done with a dark image as well
photometric_stereo.ConfigureNonUniformLightingCorrection(flat_rois)

object_rois: list[eVision.EROIBW8 | None] = [eVision.EROIBW8(), eVision.EROIBW8(),
    eVision.EROIBW8(), eVision.EROIBW8()]
# Set the object ROIs (Todo)

# Perform one or more computations, each will use the flat images (Todo)
photometric_stereo.Compute(object_rois)

# Optional: non uniform lighting correction could be disabled or (re-)enabled
# using SetEnableNonUniformLightingCorrection
```
