IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Normalized Cross-Correlation 3dSee full documentation
imagenormalizedCrossCorrelation3dImg (inImg3d,inKnlXYZ)
imagenormalizedCrossCorrelation3dImg (inImg3d,inKnlImg3d)

Detailed Description

Computes the Normalized Cross Correlation between a volume and a 3d kernel.

The three dimensional Normalized Cross-Correlation (NCC) between a volume $ InImg3d $ and a template $ InKnlXYZ $ is the 3d extension of the 2d Normalized Cross-Correlation. It is defined in spatial domain as follows :

\[ NCC(InImg3d(\textbf{x}), InKnlXYZ) = \frac{\sum \limits_{\textbf{i $ \in \aleph_{\textbf{x}}$}}{ \left( InImg3d(\textbf{x}) - \overline{InImg3d} \right) \left( InKnlXYZ(\textbf{x}+\textbf{i}) - \overline{InKnlXYZ} \right) }} {\sqrt{ \sum \limits_{\textbf{i $ \in \aleph_{\textbf{x}}$}} { \left( InImg3d(\textbf{x}) - \overline{InImg3d} \right)^2} \sum \limits_{\textbf{i $ \in \aleph_{\textbf{x}}$}} { \left( InKnlXYZ(\textbf{x}+\textbf{i}) - \overline{InKnlXYZ} \right)^2}}} \]

Where $ \textbf{x} = \left[ x, y, z \right]^T $ represents the coordinates of a voxel, $ \overline{InImg3d} $ is the mean of $ InImg3d $ in the neighbourhood defined by the kernel and $ \overline{InKnlXYZ} $ is the mean of $ InKnlXYZ $.

See Normalized Cross-Correlation 2d for an illustration of a 2d normalized cross-correlation result.

See also
http://en.wikipedia.org/wiki/Cross-correlation
Note
It is possible to call the NCC with an image provided as a template, nevertheless the algorithm still internally calculates and uses a kernel. These functions are ment to simplify the use of the function but it means that the data are copied in memory.

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLFiltering as filter

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# create a processing kernel
inKnl = PyIPSDK.rectangularKernelXYZ(1, 2, 1, [1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 0, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1],
True)
# normalized cross correlation 3d computation
outImg = filter.normalizedCrossCorrelation3dImg(inImg, inKnl)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLFiltering/Processor/NormalizedCrossCorrelation3dImg/NormalizedCrossCorrelation3dImg.h>

Code Example

// Compute the NCC
ImagePtr pOutNCCImg = normalizedCrossCorrelation3dImg(pImg, pKernel);