IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Statistical MatchSee full documentation
imagematchStatsImg (inImg,refImg,criterion)
imagematchStatsImg (inImg,refStats,criterion)

Detailed Description

adjust image dynamic range from a reference using statistics matching

This algorithm applies a LUT to the input image so that the set of statistical indicators chosen by the user computed on the input image matches with associated indicators in the reference image.

If the user wants to match the minimum and maximum values:

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

with $inMin$ and $inMax$ respectively the minimum and maximum pixel values in input image and $refMin$ and $refMax$ respectively the minimum and maximum pixel values in reference image.

If the user wants to match the mean and and the standard deviation:

\[ OutImg[i] = \frac{refStdDev*InImg[i]}{inStdDev} + refMean - \frac{inMean*refStdDev}{inStdDev} \]

with $inStdDev$ and $inMean$ respectively the standard deviation and the mean of the pixel values in input image, and $refStdDev$ and $refMean$ respectively the standard deviation and mean of the pixel values in reference image.

Input and output images must have same size.

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLIntensityTransform as itrans

Code Example

# opening of input images
inImg1 = PyIPSDK.loadTiffImageFile(inputImgPath1)
inImg2 = PyIPSDK.loadTiffImageFile(inputImgPath2)
# image statistics matching computation
outImg = itrans.matchStatsImg(inImg1, inImg2, PyIPSDK.eMatchStatsCriterion.eMeanStdDev)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLIntensityTransform/Processor/MatchStatsImg/MatchStatsImg.h>

Code Example

boost::filesystem::path inPath, refPath;
// initialization of paths
// ...
ImagePtr pInImg = loadTiffImageFile(inPath);
ImagePtr pRefImg = loadTiffImageFile(refPath);
// launch "mean/standard deviation" matching operation
ImagePtr pOutImg = matchStatsImg(pInImg, pRefImg, eMatchStatsCriterion::eMeanStdDev);