IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Normalized Cross-Correlation Measure 2d

measures the global Normalized Cross-Correlation between two images More...

IPSDKIPLGLOBALMEASURE_API ipsdk::ipReal64 ipsdk::imaproc::glbmsr::normalizedCrossCorrelationMsr2d (const ipsdk::image::ImageConstPtr &pInImg1, const ipsdk::image::ImageConstPtr &pInImg2)
 wrapper function for measures the global Normalized Cross-Correlation between two images More...
 
IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedNCCResultPtr ipsdk::imaproc::glbmsr::multiSlice_normalizedCrossCorrelationMsr2d (const ipsdk::image::ImageConstPtr &pInImg1, const ipsdk::image::ImageConstPtr &pInImg2)
 wrapper function for measures the global Normalized Cross-Correlation between two images More...
 
IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedNCCResultPtr ipsdk::imaproc::glbmsr::multiSlice_normalizedCrossCorrelationMsr3d (const ipsdk::image::ImageConstPtr &pInImg3d1, const ipsdk::image::ImageConstPtr &pInImg3d2)
 wrapper function for measures the global Normalized Cross-Correlation between two 3D images More...
 

Detailed Description

measures the global Normalized Cross-Correlation between two images

This algorithms computes the global Nocmalized Cross-Correlation (NCC) between the two input images. In opposition to the Normalized Cross-Correlation 2d algorithm which returns an image, the result of this algorithm is a a single scalar value.

The 2D NCC is calculated according to the following formula :

\[ NCC(InImg1(\textbf{x}), InImg2(\textbf{x})) = \frac{\sum_{\textbf{x} \in \Omega} (InImg1(\textbf{x}) - \overline{InImg1}) (InImg2(\textbf{x}) - \overline{InImg2}) } {\sqrt{\sum_{\textbf{x} \in \Omega} (InImg1(\textbf{x}) - \overline{InImg1})^2 \sum_{\textbf{x} \in \Omega} (InImg2(\textbf{x}) - \overline{InImg2})^2}} \]

Where $\Omega = (sizeX, sizeY)$ is the image domain definition.

The result belongs to $[-1, 1]$, and equals 1 when the images exactly matches, -1 when the images are exactly inverted and 0 when the images are totally different from each other.

The figure below illustrates the NCC behaviour for several cases. First, we show the NCC between an image and its rotation by 45° : the NCC equals approximately 0.226. Then, we calculates the NCC between an image and the ame image with the intensity inversed. The result is approximately -1. Finally, we computes the correlation between two different images. The result is approximately 0.1, i.e. close to 0.

normalizedCrossCorrelationMsr2d.png

If the input images has several slices along the Z, C or T dimensions, the result is not a scalar but a collection of ipsdk::imaproc::attr::NCCResult. This data structure stores the actual result in its Result field. The other fields can be ignored as long as they are used for the calculation.

See also
https://en.wikipedia.org/wiki/Cross-correlation for more details

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg1 [Input] First image for processing operation X
ipsdk::imaproc::attr::InImg2 [Input] Second image for processing operation X
ipsdk::imaproc::attr::OutPINCCResult [Output] Plan indexed collection of NCC results ipsdk::imaproc::fromImage (_pOutPINCCResult, _pInImg1)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSize (_pInImg1,_pInImg2) && 
ipsdk::imaproc::matchImagePlans (_pOutPINCCResult,_pInImg1,eImagePlansMatchPolicy::eIPMP_ZCT)

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLGlobalMeasure as glbmsr

Code Example

# retrieve measurement results
nccValue = glbmsr.normalizedCrossCorrelationMsr2d(inImg1, inImg2)
print("Global NCC value = " + str(nccValue))

Example of C++ code :

Example informations

Associated library

IPSDKIPLGlobalMeasure

Header file

Code Example

const ipReal64 ncc = normalizedCrossCorrelationMsr2d(pInImg1, pInImg2);
See also
NormalizedCrossCorrelationMsr2dLvl1
NormalizedCrossCorrelationMsr2dLvl2
NormalizedCrossCorrelationMsr2dLvl3

Function Documentation

◆ normalizedCrossCorrelationMsr2d()

IPSDKIPLGLOBALMEASURE_API ipsdk::ipReal64 ipsdk::imaproc::glbmsr::normalizedCrossCorrelationMsr2d ( const ipsdk::image::ImageConstPtr pInImg1,
const ipsdk::image::ImageConstPtr pInImg2 
)

wrapper function for measures the global Normalized Cross-Correlation between two images

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_normalizedCrossCorrelationMsr2d()

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedNCCResultPtr ipsdk::imaproc::glbmsr::multiSlice_normalizedCrossCorrelationMsr2d ( const ipsdk::image::ImageConstPtr pInImg1,
const ipsdk::image::ImageConstPtr pInImg2 
)

wrapper function for measures the global Normalized Cross-Correlation between two images

Note
This wrapper can be used with multi slice input images to retrieve by slice results
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ multiSlice_normalizedCrossCorrelationMsr3d()

IPSDKIPLGLOBALMEASURE_API ipsdk::imaproc::attr::PlanIndexedNCCResultPtr ipsdk::imaproc::glbmsr::multiSlice_normalizedCrossCorrelationMsr3d ( const ipsdk::image::ImageConstPtr pInImg3d1,
const ipsdk::image::ImageConstPtr pInImg3d2 
)

wrapper function for measures the global Normalized Cross-Correlation between two 3D images

Note
This wrapper can be used with multi slice input images to retrieve by slice results
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure