IPSDK 4.2
IPSDK : Image Processing Software Development Kit
Grey Inertia Measure 2d
Inertia2dDatagreyInertiaMsr2d (inImg)
Inertia2dDatagreyInertiaMsr2d (inImg,inMaskImg)

Detailed Description

Computes the global inertia based on the grey levels of the input 2D image.

This algorithm computes the second order central moment for the entire image, ponderated by the pixels intensities, thanks to the inertia matrix $ M $.

\[ M = \begin{bmatrix} m_{xx} & m_{xy} \\ m_{yx} & m_{yy} \end{bmatrix} \]

Whose components are computed as follows :

\[ \begin{array}{r c l} m_{xx} & = & \sum_{\lbrace x, y \rbrace \in \Omega}{ \left(x - \bar{x} \right)^2 I(x, y)} \\ m_{xy} = m_{yx} & = & \sum_{\lbrace x, y \rbrace \in \Omega}{ \left(x - \bar{x} \right) \left(y - \bar{y} \right) I(x, y)} \\ m_{yy} & = & \sum_{\lbrace x, y \rbrace \in \Omega}{ \left(y - \bar{y} \right)^2 I(x, y)}\\ \end{array} \]

Where $ I(x, y) $ is the image intensity at the position $ (x, y) $, $ \bar{x} $ and $ \bar{y} $ are the grey barycenter coordinates and $ \Omega $ is the set of pixel coordinates in the image.

From these composents, three descriptors are extracted : the minimum and maximum eigen values of $ M $ ( $ \lambda_{Min} $ and $ \lambda_{Max} $ ) and the global orientation $ \theta $ .

These features are calculated as follows :

\[ \begin{array}{r c l} \delta & = & \sqrt{(m_{xx} - m_{yy}) (m_{xx} - m_{yy}) + 4 m_{xy} m_{xy}} \\ \lambda_{Max} & = & \frac{1}{2} \left( m_{xx} + m_{yy} + \delta \right) \\ \lambda_{Min} & = & \frac{1}{2} \left( m_{xx} + m_{yy} - \delta \right) \\ \theta & = & \tan^{-1} \left( \frac{\lambda_{Max} - m_{xx}}{m_{xy}} \right) \end{array} \]

$ \lambda_{Min} $ and $ \lambda_{Max} $ are proportional to the squared length of the eigenvector axes, represented by green arrows in the figure below.

greyInertia2dMsr_illustration.png

Here is an example of result for a grey level image:

GreyInertiaMsr2d.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLGlobalMeasure as glbmsr

Code Example

# Pixel localization computation
outInertia2d = glbmsr.greyInertiaMsr2d(inImg)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLGlobalMeasure/Processor/GreyInertiaMsr2d/GreyInertiaMsr2d.h>

Code Example

// compute the pixel locations
Inertia2dDataPtr pInertia = greyInertiaMsr2d(pInImg);