IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

normalizes the intensity of an image from an optional given input range $InOptInputRange = [inMin, inMax]$ to a given output range $InOutputRange = [outMin, outMax]$ More...

IPSDKIPLINTENSITYTRANSFORM_API ipsdk::image::ImagePtr ipsdk::imaproc::itrans::normalizeImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::RangeConstPtr &pInputRange, const ipsdk::imaproc::attr::RangeConstPtr &pOutputRange)
 wrapper function for linear normalization of the intensity of an image More...
 
IPSDKIPLINTENSITYTRANSFORM_API void ipsdk::imaproc::itrans::normalizeImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::RangeConstPtr &pInputRange, const ipsdk::imaproc::attr::RangeConstPtr &pOutputRange, const ipsdk::image::ImagePtr &pOutImg)
 wrapper function for linear normalization of the intensity of an image More...
 
IPSDKIPLINTENSITYTRANSFORM_API image::ImagePtr ipsdk::imaproc::itrans::normalizeImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::RangeConstPtr &pOutputRange)
 wrapper function for linear normalization of the intensity of an image More...
 
IPSDKIPLINTENSITYTRANSFORM_API void ipsdk::imaproc::itrans::normalizeImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::RangeConstPtr &pOutputRange, const ipsdk::image::ImagePtr &pOutImg)
 wrapper function for linear normalization of the intensity of an image More...
 

Detailed Description

normalizes the intensity of an image from an optional given input range $InOptInputRange = [inMin, inMax]$ to a given output range $InOutputRange = [outMin, outMax]$

Note
If optional input range is not provided, image minimum and maximum intensities are used.

On output image, values are given by:

\[ OutImg[i] = \begin{cases} outMin & \text { if } inImg[i] < inMin \\ outMax & \text { if } inImg[i] > inMax \\ (InImg[i] - inMin) * \dfrac {outMax - outMin} {inMax - inMin} + outMin & \text { otherwise} \end{cases} \]

with $[inMin, inMax]$ and $[outMin, outMax]$ respectively the input and output ranges specified by the user.

Here is an example of intensity normalization applied to a 8-bits grey level image with $[outMin, outMax]=[0, 255]$:

normalizeImg.png

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InOptInputRange [Input Optional] image intensity range for algorithm X
ipsdk::imaproc::attr::InOutputRange [Input] output image intensity range for algorithm 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) && 
ipsdk::processor::ifIsSet (
 _pInOptInputRange, (ipsdk::imaproc::matchImageRange<ipsdk::imaproc::attr::Range::Min>(_pInImg,_pInOptInputRange) && ipsdk::imaproc::matchImageRange<ipsdk::imaproc::attr::Range::Max>(_pInImg,_pInOptInputRange))) && (ipsdk::imaproc::matchImageRange<ipsdk::imaproc::attr::Range::Min>(_pOutImg,_pInOutputRange) && ipsdk::imaproc::matchImageRange<ipsdk::imaproc::attr::Range::Max>(_pOutImg,_pInOutputRange))

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLIntensityTransform as itrans

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# definition of targeted image output range
outputRange = PyIPSDK.createRange(50, 200)
# image normalization computation
outImg = itrans.normalizeImg(inImg, outputRange)

Example of C++ code :

Example informations

Associated library

IPSDKIPLIntensityTransform

Header file

Code Example

// Sample with a generated output image
// ------------------------------------
ImagePtr pAutoOutImg;
if(pInRange.get() != 0) {
// Sample with a generated output image
// ------------------------------------
pAutoOutImg = normalizeImg(pInImg, pInRange, pOutRange);
// Sample with a provided output image
// -----------------------------------
// normalize input image
itrans::normalizeImg(pInImg, pInRange, pOutRange, pOutImg);
}
else {
// Sample with a generated output image
// ------------------------------------
pAutoOutImg = normalizeImg(pInImg, pOutRange);
// Sample with a provided output image
// -----------------------------------
// create output image
ImageGeometryPtr pOutputImageGeometry = geometry2d(outType, sizeX, sizeY);
pOutImg = boost::make_shared<MemoryImage>();
pOutImg->init(*pOutputImageGeometry);
// normalize input image
normalizeImg(pInImg, pOutRange, pOutImg);
}
See also
NormalizeImgLvl1
NormalizeImgLvl2
NormalizeImgLvl3

Function Documentation

◆ normalizeImg() [1/4]

IPSDKIPLINTENSITYTRANSFORM_API ipsdk::image::ImagePtr ipsdk::imaproc::itrans::normalizeImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::RangeConstPtr pInputRange,
const ipsdk::imaproc::attr::RangeConstPtr pOutputRange 
)

wrapper function for linear normalization of the intensity of an image

Parameters
pInImginput image to normalize
pInputRangeinput intensity range
pOutputRangeoutput intensity range, after normalization
Note
if pInputRange argument is not entered by the user, input range will equal to the dynamic range of the image, automatically computed from a call to glbmsr::statsMsr function on the input image
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ normalizeImg() [2/4]

IPSDKIPLINTENSITYTRANSFORM_API void ipsdk::imaproc::itrans::normalizeImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::RangeConstPtr pInputRange,
const ipsdk::imaproc::attr::RangeConstPtr pOutputRange,
const ipsdk::image::ImagePtr pOutImg 
)

wrapper function for linear normalization of the intensity of an image

Parameters
pInImginput image to normalize
pInputRangeinput intensity range
pOutputRangeoutput intensity range, after normalization
Note
if pInputRange argument is not entered by the user, input range will equal to the dynamic range of the image, automatically computed from a call to glbmsr::statsMsr function on the input image
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ normalizeImg() [3/4]

IPSDKIPLINTENSITYTRANSFORM_API image::ImagePtr ipsdk::imaproc::itrans::normalizeImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::RangeConstPtr pOutputRange 
)

wrapper function for linear normalization of the intensity of an image

Parameters
pInImginput image to normalize
pInputRangeinput intensity range
pOutputRangeoutput intensity range, after normalization
Note
if pInputRange argument is not entered by the user, input range will equal to the dynamic range of the image, automatically computed from a call to glbmsr::statsMsr function on the input image
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ normalizeImg() [4/4]

IPSDKIPLINTENSITYTRANSFORM_API void ipsdk::imaproc::itrans::normalizeImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::RangeConstPtr pOutputRange,
const ipsdk::image::ImagePtr pOutImg 
)

wrapper function for linear normalization of the intensity of an image

Parameters
pInImginput image to normalize
pInputRangeinput intensity range
pOutputRangeoutput intensity range, after normalization
Note
if pInputRange argument is not entered by the user, input range will equal to the dynamic range of the image, automatically computed from a call to glbmsr::statsMsr function on the input image
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure