最近急用 终于找到了 原文地址:矩阵卷积作者:yjssx来源: xcorr2 syntax c = xcorr2(a,b) xcorr2(a) description c = xcorr2(a,b) ret rns the cross-correlation of matrices a and b with no scaling. xcorr2 is the two-dimensional version of xcorr. it has its maxim m val e when the two matrices are aligned so that they are shaped as similarly as possible. if matrix a has dimensions (ma, na) and matrix b has dimensions (mb, nb), the eq ation for the two-dimensional discrete cross-correlation is where and . xcorr2(a) is the a tocorrelation matrix of inp t matrix a. it is identical to xcorr2(a,a). examples o tp t matrix size if matrix i1 has dimensions (4,3) and matrix i2 has dimensions (2,2), the following eq ations determine the n mber of rows and col mns of the o tp t matrix: the res lting matrix is comp ting a specific element in cross-correlation, the val e of an o tp t element is comp ted as a weighted s m of neighboring elements. for example, s ppose the first inp t matrix represents an image and is defined as i1 = [17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9] the second inp t matrix also represents an image and is defined as i2 = [8 1 6 3 5 7 4 9 2] the following fig re shows how to comp te the (2,4) o tp t element (zero-based indexing) sing these steps: slide the center element of i2 so that lies on top of the (1,3) element of i1. m ltiply each weight in i2 by the element of i1 nderneath. s m the individ al prod cts from step 2. the (2,4) o tp t element from the cross-correlation is the normalized cross-correlation of the (2,4) o tp t element is 585sqrt(s m(dot(i1p,i1p))*s m(dot(i2,i2 = 0.8070 where i1p = [1 8 15; 7 14 16;