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 :
- for the whole grey level 2d image,
- for each channel of a color image,
- for each slice of a volume,
- for each frame in a 2d sequence,
- ...
- for each channel of each slice of each volume of an RGB volume sequence.
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:
- an input image
, whose levels are encoded on a given data type
. We will note minimal and maximal values of
and
(ex.: for
=uint8,
equals to 0 and
equals to 255; for
=int8,
equals to -128 and
equals to 127)
- a given level interval width
;
if image levels are encoded on integers,
otherwise
- a range
, with
and 
Then, we can split the range
in
intervals
(
integer,
) and one interval
. These intervals are adjacent.
If images levels are encoded on floating values, then
Else,
Then, the histogram of input parameters
,
and
computed on
is the collection
(
integer,
), with
the number of pixels in
whose levels belong to
.
There are different ways to compute the histogram of an input image:
- by specifying the input image only; histogram min and max values are then automatically initialized with the minimal and maximal values of the image, and the number of classes in the histogram equals to 256
- by specifying the input image, and the parameters (bin width) or (histogram min, histogram max and bin width) (in the first case, histogram min and histogram max are automatically set to image min and max)
- by specifying the input image, and the parameters (number of classes) or (histogram min, histogram max and number of classes) (in the first case, histogram min and histogram max are automatically set to image min and max)
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLGlobalMeasure as glbmsr
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
histogramMsrParams = PyIPSDK.createHistoMsrParamsWithBinWidth(0, 255, 2)
histogramMsr2dResult = glbmsr.histogramMsr2d(inImg, histogramMsrParams)
frequencies = histogramMsr2dResult.frequencies
print("Population for bin [100, 101] is " + str(frequencies[50]))
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLGlobalMeasure/Processor/HistogramMsr2d/HistogramMsr2d.h>
Code Example
PlanIndexedHistogramDataPtr pHistogram_multiSlice = multiSlice_histogramMsr2d(pInImg_multiSlice);