IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Localy adjust the contrast of an image. More...

IPSDKIPLINTENSITYTRANSFORM_API ipsdk::image::ImagePtr ipsdk::imaproc::itrans::adaptiveContrastEnhancement2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipUInt32 inHalfKnlSizeX, const ipUInt32 inHalfKnlSizeY, const ipReal64 inArithmeticVal, const ipReal32 inBlendMultiplier)
 wrapper function for Localy adjust the contrast of an image More...
 
IPSDKIPLINTENSITYTRANSFORM_API void ipsdk::imaproc::itrans::adaptiveContrastEnhancement2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipUInt32 inHalfKnlSizeX, const ipUInt32 inHalfKnlSizeY, const ipReal64 inArithmeticVal, const ipReal32 inBlendMultiplier, const image::ImagePtr &pOutImg)
 wrapper function for Localy adjust the contrast of an image More...
 

Detailed Description

Localy adjust the contrast of an image.

This algorithm computes a new intensity according to its neighbour in order to locally enhance the image contrast.

Each pixel intensity is calculated according to a relative percentage of its neighbourhood intensities. The calculation is comparable to the Contrast Limited Adaptive Histogram Equalization (CLAHE) [1], although it remains much less heavy. Contrary to the CLAHE, it is possible to compute the contrast to each pixel in a reasonable amount of time.

In order to reduce the impact of the noise, a tolerance threshold $InArithmeticVal$ is used to make the algorithm consider that a neighbour has the same intensity than the current pixel if $|InImg[x] - InImg[n]| < InArithmeticVal$, where $x$ is the coordinate of the current pixel, $n$ is the coordinate of its neighbour.

The output intensities may differ a lot from the original images. For this reason, the input image is mixed with the adaptive contrast enhancement result to generate an output looking like the input image. It is possible to tune this effect thanks to the inBlendMultiplier parameter. A blend coefficient of 0 means that the output is the direct result of the enhancement and a blend value of 1 will yield the input image.

Here is an example of an adaptive contrast enhancement operation applied to a grey level image.
kernel size = 15, offset = 15, blend value = 0.5.

adaptiveContrastEnhancementImg.png

[1] Zuiderveld, Karel. "Contrast Limited Adaptive Histograph Equalization." Graphic Gems IV. San Diego: Academic Press Professional, 1994. 474-485.

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InHalfKnlSizeX [Input] half kernel size along X axis for operation X
ipsdk::imaproc::attr::InHalfKnlSizeY [Input] half kernel size along Y axis for operation X
ipsdk::imaproc::attr::InArithmeticVal [Input] value used for arithmetic operations X
ipsdk::imaproc::attr::InBlendMultiplier [Input] Multiplier value used for image blending operation X
ipsdk::imaproc::attr::OutImg [Output] image for processing operation ipsdk::imaproc::duplicateInOut (_pOutImg, _pInImg)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSize (_pInImg,_pOutImg)

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLIntensityTransform as itrans

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# Set up the parameters
halfKnlSizeX = 15;
halfKnlSizeY = 15;
intensityTolerance = 10;
blendRatio = 0.5;
# computation of image histogram
outImg = itrans.adaptiveContrastEnhancement2dImg(inImg, halfKnlSizeX, halfKnlSizeY, intensityTolerance, blendRatio)

Example of C++ code :

Example informations

Associated library

IPSDKIPLIntensityTransform

Header file

Code Example

// Set up the parameters
const ipUInt64 halfKnlSizeX = 15;
const ipUInt64 halfKnlSizeY = 15;
const ipReal64 intensityTolerance = 10;
const ipReal64 blendRatio = 0.5;
// Process the image
ImagePtr pOutImg = adaptiveContrastEnhancement2dImg(pInImg, halfKnlSizeX, halfKnlSizeY, intensityTolerance, blendRatio);
See also
AdaptiveContrastEnhancement2dImgLvl1
AdaptiveContrastEnhancement2dImgLvl2
AdaptiveContrastEnhancement2dImgLvl3

Function Documentation

◆ adaptiveContrastEnhancement2dImg() [1/2]

IPSDKIPLINTENSITYTRANSFORM_API ipsdk::image::ImagePtr ipsdk::imaproc::itrans::adaptiveContrastEnhancement2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipUInt32  inHalfKnlSizeX,
const ipUInt32  inHalfKnlSizeY,
const ipReal64  inArithmeticVal,
const ipReal32  inBlendMultiplier 
)

wrapper function for Localy adjust the contrast of an image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ adaptiveContrastEnhancement2dImg() [2/2]

IPSDKIPLINTENSITYTRANSFORM_API void ipsdk::imaproc::itrans::adaptiveContrastEnhancement2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipUInt32  inHalfKnlSizeX,
const ipUInt32  inHalfKnlSizeY,
const ipReal64  inArithmeticVal,
const ipReal32  inBlendMultiplier,
const image::ImagePtr pOutImg 
)

wrapper function for Localy adjust the contrast of an image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure