IPSDK 0.2
IPSDK : Image Processing Software Development Kit
imagelightnessImg (inColorImg)
imagelightnessImg (inColorImg,lightnessType)

Detailed Description

lightness computation for an input color image

The algorithm converts a color image to a grey level one according to one of the three possible types: Average, Lightness or Luminance. The default value is Average.

Assuming that $InColorImg[i, c]$ is the $i^{th}$ pixel in the channel $c$, we can define the three different ways to calculate the lightness.

For the Average type, the output image values are given by:

\[ OutLightImg[i] = \frac{\sum_{c}{InColorImg[i, c]}} {NbChannels} \]

For the Lightness type, the output image values are given by:

\[ OutLightImg[i] = \frac{\max_{c}(InColorImg[i, c]) + \min_{c}(InColorImg[i, c])} {2} \]

The Luminance type can only be calculated for images with three channels and is assumed to be RGB. The output image values are given by:

\[ OutLightImg[i] = 0.21 InColorImg[i, 0] + 0.72 InColorImg[i, 1] + 0.07 InColorImg[i, 2] \]

Input and output images must have same size (but color size).

Here is an example of an average ligthness operation applied to a 8-bits RGB color image:

lightnessImgExample.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLColor as color

Code Example

# opening of input image
geometryRgb = PyIPSDK.geometryRgb2d(PyIPSDK.eImageBufferType.eIBT_UInt8, 510, 509)
inImg = PyIPSDK.loadRawImageFile(inputImgPath, geometryRgb)
# lightness computation
outImg = color.lightnessImg(inImg)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLColor/Processor/LightnessImg/LightnessImg.h>

Code Example

// opening input image
ImagePtr pInColorImg = loadTiffImageFile(inputImgPath);
// compute lightness on input image
ImagePtr pOutLightImg = lightnessImg(pInColorImg, lightnessType);