Differences between revisions 9 and 10
 ⇤ ← Revision 9 as of 2013-02-19 23:10:47 → Size: 2227 Editor: ppp Comment: ← Revision 10 as of 2013-07-01 13:12:40 → ⇥ Size: 2227 Editor: localhost Comment: converted to 1.6 markup No differences found!

# Name

ccfnpl - calculate the normalized cross-correlation function between two images using padding with zeroes, multiplication in Fourier space, and normalization of the result by the actual number of pixels used for calculating the ccf coefficients.

# Usage

output = ccfnpl(image, ref, center=True)

## Input

image
input image (real)
ref
second input image (real) (in the alignment problems, it should be the reference image).
center
if set to True (default), the origin of the result is at the center; if set to False, the origin is at (0,0), the option is much faster, but the result is difficult to use

## Output

output
cross-correlation function between image and ref. Real. The origin of the cross-correlation function (term ccf(0,0,0)) is located at (int[n/2], int[n/2], int[n/2]) in 3D, (int[n/2], int[n/2]) in 2D, and at int[n/2] in 1D.

# Method

• In order to calculate the normalized and lag-normalized cross-correlation function between image f and reference image g, first both images are normalized by subtracting their respective averages and by dividing by their respective standard deviations. Next, Fourier transforms of both images are calculated, then their product in Fourier space as `hat(f)hat(g)^**`, then the inverse Fourier transform, the ccfnpl is windowed out using the size of original images, and the resulting cross-correlation function is normalized by the lag, i.e., the actual number of pixels in image that entered the calculation.

• In real space, this corresponds to:
• `c\cfnpl(n)=(1/(nx-|n|)sum_(k=0)^(nx-1)f((k+n)-Ave_f)(g(k)-Ave_g))/(sigma_f sigma_g)`

• `n = -(nx)/2, ..., (nx)/2`

• with the assumption that `g(k)=0 fo\r k<0 or kgenx`

• Note: ccfnpl is free from "wrap around" artifacts.

# Reference

Pratt, W. K., 1992. Digital image processing. Wiley, New York.

Pawel A. Penczek

category 1
FUNDAMENTALS
category 2
FOURIER

fundamentals.cpp

# Maturity

stable
works for most people, has been tested; test cases/examples available.

# Bugs

None. It is perfect.

ccfnpl (last edited 2013-07-01 13:12:40 by localhost)