![]() |
The open imaging DSP library
|
Use libmpix to apply image correction to improve contrasts and colors.
Raw images coming from a sensor are typically too dark or over-exposed, with green colors and other visible defects.
Some of the defects cannot be corrected (too much noise, over-exposure), and some are expected and corrected as part of any classical image correction pipeline.
If the image arrives without such defects, this suggests that the correction is included inside the image sensor or the video acquisition hardware.
The input format is always specified when opening the image and does not need to be specified. What remains to do is to call mpix_image_convert and specify the output pixel format.
First load a buffer into an image struct, specifying the pixel format:
Each type of correction have their own struct, all of which are represented as members of the mpix_correction_all struct (convenient to store all parameters) and mpix_correction_any (used to control a particular operation).
To control the correction level, you may adjust each parameter to fit a particular camera and light condition manually:
MPIX_CID_BLACK_LEVEL
is the value to subtract to every pixel to set the black back to 0. This can be set to the minimum value you observe in an image and rarely needs to be updated.MPIX_CID_RED_BALANCE
and MPIX_CID_BLUE_BALANCE
are defined as a proportion to the green channel, with 1.0 mapped to 1024. Let's try to apply x2 to both blue and red to correct the green tint: 1024 * 2 = 2048
.MPIX_CID_GAMMA_LEVEL
gamma correction to non-linearly increase the brightness: dark/bright colors remain dark/bright but intermediate tones become brighter to reflect eye's natural light sensitivity. Contrasts will appear more natural and accurate.Then, apply each step of the correction you wish to the image:
It is now possible to apply extra correction to it (where 1 << 10
is to convert to fixed-point):
The image will now be corrected using each of the steps specified.
See Supported operations for a list of all supported image correction operations.