C = conv2(X,Y)
C = conv2(X,Y,'shape')
C = conv2(X,Y)computes the two-dimensional convolution of matrices
Y. If one of these matrices describes a two-dimensional FIR filter, the other matrix is filtered in two dimensions.
The size in each dimension of the output matrix
C is equal to the sum of the corresponding dimensions of the input matrices minus one. That is, if the size of
[mx nx] and the size of
[my ny], then the size of
C = conv2(X,Y,'shape') returns a subsection of the two-dimensional convolution, as specified by the
fullreturns the full two-dimensional convolution (default).
samereturns the central part of the convolution of the same size as
validreturns only those parts of the convolution that are computed without the zero-padded edges. Using this option,
conv2executes most quickly when
Xis larger than
These commands extract the horizontal edges from a raised pedestal:
s = [1 2 1; 0 0 0; -1 -2 -1];
These commands display first the vertical edges of
A = zeros(10);
A(3:7,3:7) = ones(5);
h = conv2(A,s);
A, then both horizontal and vertical edges.
V = conv2(A,s');
(c) Copyright 1994 by The MathWorks, Inc.