Correlation is similar to convolution, except that you do not need to transfer the input signal about the origin (but the correlation needs take the complex conjugation of one of the operands), so for three-dimensional real matrices you can use convn(x3d,y3d(end:-1:1,end:-1:1,end:-1:1))Three-dimensional correlation to calculate.
source
share