2D Correlation is typically used to detect similarities between two 2D signals, which are often saved in matrices. The 2D correlation of two matrices, a and b, can be defined as follows:
There are two methods for 2D correlation computation: FFT and Shift-Accumulation. If shift accumulation is chosen, the result will be computed from the definition of correlation. If FFT is chosen, the computation of 2D correlation is actually carried out as follows:
Generally speaking, the FFT method can accelerate the computation for large data, but it is sometimes inaccurate for some data points near the boundaries due to the nature of FFT.