IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

lightness computation for an input color image More...

IPSDKIPLCOLOR_API void ipsdk::imaproc::color::lightnessImg (const image::ImageConstPtr &pInColorImg, const image::ImagePtr &pOutLightImg)
 wrapper function for lightness computation from an input RGB color image More...
 
IPSDKIPLCOLOR_API image::ImagePtr ipsdk::imaproc::color::lightnessImg (const image::ImageConstPtr &pInColorImg)
 wrapper function for lightness computation from an input RGB color image More...
 
IPSDKIPLCOLOR_API void ipsdk::imaproc::color::lightnessImg (const image::ImageConstPtr &pInColorImg, const ipsdk::imaproc::attr::eLightnessType &lightnessType, const image::ImagePtr &pOutLightImg)
 wrapper function for lightness computation from an input RGB color image More...
 
IPSDKIPLCOLOR_API image::ImagePtr ipsdk::imaproc::color::lightnessImg (const image::ImageConstPtr &pInColorImg, const ipsdk::imaproc::attr::eLightnessType &lightnessType)
 wrapper function for lightness computation from an input RGB color image More...
 

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

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InColorImg [Input] color image for processing operation X
ipsdk::imaproc::attr::InLightnessType [Input] Type of conversion to obtain a grey level image from a color image X
ipsdk::imaproc::attr::OutLightImg [Output] lightness image duplicateGreyInOut (_pOutLightImg, _pInColorImg)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSize (eMatchImageSizeType::eMIST_XYZT,_pInColorImg,_pOutLightImg) && 
ipsdk::imaproc::matchBufferType (_pInColorImg,_pOutLightImg)

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

Associated library

IPSDKIPLColor

Header file

Code Example

// opening input image
ImagePtr pInColorImg = loadTiffImageFile(inputImgPath);
// compute lightness on input image
ImagePtr pOutLightImg = lightnessImg(pInColorImg, lightnessType);
See also
LightnessImgLvl1
LightnessImgLvl2
LightnessImgLvl3

Function Documentation

◆ lightnessImg() [1/4]

IPSDKIPLCOLOR_API void ipsdk::imaproc::color::lightnessImg ( const image::ImageConstPtr pInColorImg,
const image::ImagePtr pOutLightImg 
)

wrapper function for lightness computation from an input RGB color image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ lightnessImg() [2/4]

IPSDKIPLCOLOR_API image::ImagePtr ipsdk::imaproc::color::lightnessImg ( const image::ImageConstPtr pInColorImg)

wrapper function for lightness computation from an input RGB color image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ lightnessImg() [3/4]

IPSDKIPLCOLOR_API void ipsdk::imaproc::color::lightnessImg ( const image::ImageConstPtr pInColorImg,
const ipsdk::imaproc::attr::eLightnessType lightnessType,
const image::ImagePtr pOutLightImg 
)

wrapper function for lightness computation from an input RGB color image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ lightnessImg() [4/4]

IPSDKIPLCOLOR_API image::ImagePtr ipsdk::imaproc::color::lightnessImg ( const image::ImageConstPtr pInColorImg,
const ipsdk::imaproc::attr::eLightnessType lightnessType 
)

wrapper function for lightness computation from an input RGB color image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure