IPSDK 0.2
IPSDK : Image Processing Software Development Kit
imagevariance2dImg (inImg,inHalfKnlSizeX,inHalfKnlSizeY)

Detailed Description

local 2d image variance computation

This algorithm computes for each pixel of output image associated local variance on a rectangular neighbourhood of input image.

Given an input image $InImg$ and rectangular kernel half sizes $N_x = InHalfKnlSizeX$ and $N_y = InHalfKnlSizeY$, output image values are given by :

\[ OutImg[x, y] = \dfrac{1}{(2 N_y + 1)(2 N_x + 1)}\sum_{o_{y}=-N_y}^{N_y}{\sum_{o_{x}=N_x}^{N_x}{(InImg[x, y]-\bar{M}[x, y])^2}} \]

where

\[ \bar{M}[x, y] = \dfrac{1}{(2 N_y + 1)(2 N_x + 1)}\sum_{o_{y}=-N_y}^{N_y}{\sum_{o_{x}=N_x}^{N_x}{InImg[x, y]}} \]

See also
http://en.wikipedia.org/wiki/Variance

Here is an example of a Variance computation applied on a 8 bits grey level image with $InHalfKnlSizeX = InHalfKnlSizeY = 2$:

variance2dImg.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLStats as stats

Code Example

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

Example of C++ code :

Example informations

Header file

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

Code Example

// opening input image
ImageGeometryPtr pInImageGeometry = geometry2d(imageBufferType, sizeX, sizeY);
ImagePtr pInImg = loadRawImageFile(inputImgPath, *pInImageGeometry);
// compute variance on input image
ImagePtr pOutImg = variance2dImg(pInImg, inHalfKnlSizeX, inHalfKnlSizeY);