IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

calculates the histogram for each 2d plan of an input image More...

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::HistogramDataPtr ipsdk::imaproc::glbmsr::histogramMsr2d (const image::ImageConstPtr &pInImg)
 wrapper function for calculates the histogram for each 2d plan of an input image More...
 
IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::HistogramDataPtr ipsdk::imaproc::glbmsr::histogramMsr2d (const image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::HistoMsrParamsConstPtr &pHistoPrms)
 wrapper function for calculates the histogram for each 2d plan of an input image More...
 
IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedHistogramDataPtr ipsdk::imaproc::glbmsr::multiSlice_histogramMsr2d (const image::ImageConstPtr &pInImg)
 wrapper function for calculates the histogram for each 2d plan of an input image More...
 
IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedHistogramDataPtr ipsdk::imaproc::glbmsr::multiSlice_histogramMsr2d (const image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::HistoMsrParamsConstPtr &pHistoPrms)
 wrapper function for calculates the histogram for each 2d plan of an input image More...
 

Detailed Description

calculates the histogram for each 2d plan of an input image

The histogram of an image is generally used as a tool to visualize the distribution of grey levels of the pixels of an image.

This algorithm computes the histogram for each 2d plan of the input image. In other words, the results will be computed :

Two wrappers can be called : the histogramMsr2d wrapper is only used to compute the histogram measurements on a grey level 2d image, whereas the multiSlice_histogramMsr2d wrapper must be used for more complex data (volume, sequence and/or color).

Consider:

Then, we can split the range $[min_{idt}; max_{idt}]$ in $nbClasses-1$ intervals $binIntvl_i = [min_{histo}+(i-1)*binWidth, min_{histo}+i*binWidth[ $ ( $i$ integer, $i \in {[1; nbClasses-1]}$) and one interval $binIntvl_{nbClasses} = [min_{histo}+(nbClasses-1)*binWidth; max_{histo}]$. These intervals are adjacent.

If images levels are encoded on floating values, then

\[ nbClasses = \dfrac {max_{idt}-min_{idt}} {binWidth} \]

Else,

\[ nbClasses = \begin{cases} \left\lfloor{\dfrac {max_{idt}-min_{idt}} {binWidth}} \right\rfloor & \text { if remainder of $\dfrac {max_{idt}-min_{idt}} {binWidth}$ equals to 0} \\ \left\lfloor{\dfrac {max_{idt}-min_{idt}} {binWidth}} \right\rfloor + 1 & \text { otherwise} \end{cases} \]

Then, the histogram of input parameters $min_{histo}$, $max_{histo}$ and $binWidth$ computed on $inImg$ is the collection $\left\{n_i\right\}$ ( $i$ integer, $i \in [1; nbClasses]$), with $n_i$ the number of pixels in $inImg$ whose levels belong to $binIntvl_i$.

There are different ways to compute the histogram of an input image:

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InOptHistoMsrParams [Input Optional] histogram measure parameters X
ipsdk::imaproc::attr::OutPIHistogram [Output] Plan indexed collection of histogram properties ipsdk::imaproc::fromImage (_pOutPIHistogram, _pInImg)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchImagePlans (_pOutPIHistogram,_pInImg,eImagePlansMatchPolicy::eIPMP_ZCT) && 
(ipsdk::processor::ifIsSet (_pInOptHistoMsrParams,ipsdk::imaproc::matchImageRange<ipsdk::imaproc::attr::HistoMsrParams::Min>(_pInImg,_pInOptHistoMsrParams) && ipsdk::imaproc::matchImageRange<ipsdk::imaproc::attr::HistoMsrParams::Max>(_pInImg,_pInOptHistoMsrParams) && ipsdk::processor::isGreater<ipsdk::imaproc::attr::HistoMsrParams::BinWidth>(_pInOptHistoMsrParams,0)))

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLGlobalMeasure as glbmsr

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# definition of histogram measure parameters (optional step)
histogramMsrParams = PyIPSDK.createHistoMsrParamsWithBinWidth(0, 255, 2)
# statistics measurement
histogramMsr2dResult = glbmsr.histogramMsr2d(inImg, histogramMsrParams)
# retrieve measurement results
frequencies = histogramMsr2dResult.frequencies
print("Population for bin [100, 101] is " + str(frequencies[50]))

Example of C++ code :

Example informations

Associated library

IPSDKIPLGlobalMeasure

Header file

Code Example

// ------------ Calculation on a mono-slice grey level image ------------ //
// Load the input image
ImagePtr pInImg = loadTiffImageFile(inImgPath);
// Compute statistics on input image
HistogramDataPtr pHistogram = histogramMsr2d(pInImg);
// ------------ Calculation on a mono-slice grey level image ------------ //
// Load the input image
ImagePtr pInImg_multiSlice = loadTiffImageFile(inImgPath_multiSlice);
// Compute statistics on input image
PlanIndexedHistogramDataPtr pHistogram_multiSlice = multiSlice_histogramMsr2d(pInImg_multiSlice);
See also
HistogramMsr2dLvl1
HistogramMsr2dLvl2
HistogramMsr2dLvl3

Function Documentation

◆ histogramMsr2d() [1/2]

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::HistogramDataPtr ipsdk::imaproc::glbmsr::histogramMsr2d ( const image::ImageConstPtr pInImg)

wrapper function for calculates the histogram for each 2d plan of an input image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_histogramMsr2d() [1/2]

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedHistogramDataPtr ipsdk::imaproc::glbmsr::multiSlice_histogramMsr2d ( const image::ImageConstPtr pInImg)

wrapper function for calculates the histogram for each 2d plan of an input image

Note
This wrapper can be used with multi slice input images to retrieve by slice results
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ histogramMsr2d() [2/2]

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::HistogramDataPtr ipsdk::imaproc::glbmsr::histogramMsr2d ( const image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::HistoMsrParamsConstPtr pHistoPrms 
)

wrapper function for calculates the histogram for each 2d plan of an input image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_histogramMsr2d() [2/2]

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedHistogramDataPtr ipsdk::imaproc::glbmsr::multiSlice_histogramMsr2d ( const image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::HistoMsrParamsConstPtr pHistoPrms 
)

wrapper function for calculates the histogram for each 2d plan of an input image

Note
This wrapper can be used with multi slice input images to retrieve by slice results
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure