IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Local Entropy 2dSee full documentation
imagelocalEntropy2dImg (inImg,inHalfKnlSizeX,inHalfKnlSizeY)
imagelocalEntropy2dImg (inImg,inHalfKnlSizeX,inHalfKnlSizeY,inOptNbClasses)

Detailed Description

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 $InImg$, rectangular kernel half sizes $N_x = InHalfKnlSizeX$ and $N_y = InHalfKnlSizeY$ and a number of classes $n$, output image values are given by :

\[ OutImg[x, y] = -\sum_{i=0}^{n}{p(i).log(p(i))} \]

where:

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:

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:

localEntropy2dImg.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLStats as stats

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# local entropy 2d image computation
outImg = stats.localEntropy2dImg(inImg, 3, 3)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLStats/Processor/LocalEntropy2dImg/LocalEntropy2dImg.h>

Code Example

// opening input image
ImageGeometryPtr pInImageGeometry = geometry2d(imageBufferType, sizeX, sizeY);
ImagePtr pInImg;
if(inputImgPath.extension().string() == ".raw")
pInImg = loadRawImageFile(inputImgPath, *pInImageGeometry);
else
pInImg = loadTiffImageFile(inputImgPath);
// compute local entropy on input image
ImagePtr pOutImg = localEntropy2dImg(pInImg, inHalfKnlSizeX, inHalfKnlSizeY, nbClasses);