image = | localEntropy2dImg (inImg,inHalfKnlSizeX,inHalfKnlSizeY) |
image = | localEntropy2dImg (inImg,inHalfKnlSizeX,inHalfKnlSizeY,inOptNbClasses) |
local 2d image entropy computation
This algorithm computes for each pixel of output image associated local entropy on a rectangular neighbourhood of input image
Given an input image
, rectangular kernel half sizes
and
and a number of classes
, output image values are given by :
where:
corresponds to the natural logarithm function
equals to
, with
the number of pixels in kernel whose value belongs to the interval of the ith bin of the histogram computed on the rectangular kernel, with following parameters:
- number of classes =

= minimum value of the whole input image
= maximum value of the whole input image
The number of classes is an optional parameter of the algorithm. Its default value equals to 16. If the number of classes specified by the user exceeds the maximum allowed number of classes given the input image data type and dynamic range, it is automatically adjusted. For instance:
- a number of classes initialized to value 16 will be automatically adjusted to value 2 for a binary input image.
- a number of classes initialized to value 256 will be automatically adjusted to value 10 for a integral input image whose dynamic range equals to
![$[10;19]$](form_1201.png)
Borders of input image are processed as followed: padding pixels are a mirror reflection of the border pixels in the input image (see Border policy for more details).
Here is an example of an output image computed from the LocalEntropy2dImg algorithm on a 8-bits grey level, with a kernel of size 3 pixels x 3 pixels and 16 classes:
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLStats as stats
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
outImg = stats.localEntropy2dImg(inImg, 3, 3)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLStats/Processor/LocalEntropy2dImg/LocalEntropy2dImg.h>
Code Example
ImagePtr pInImg;
if(inputImgPath.extension().string() == ".raw")
else
ImagePtr pOutImg = localEntropy2dImg(pInImg, inHalfKnlSizeX, inHalfKnlSizeY, nbClasses);