MATLAB Function Reference    
conv2

Two-dimensional convolution

Syntax

Description

C = conv2(A,B) computes the two-dimensional convolution of matrices A and B. If one of these matrices describes a two-dimensional FIR filter, the other matrix is filtered in two dimensions.

The size of C in each dimension is equal to the sum of the corresponding dimensions of the input matrices, minus one. That is, if the size of A is [ma,na] and the size of B is [mb,nb], then the size of C is [ma+mb-1,na+nb-1].

C = conv2(hcol,hrow,A) convolves A separably with hcol in the column direction and hrow in the row direction. hcol and hrow should both be vectors.

C = conv2(...,'shape') returns a subsection of the two-dimensional convolution, as specified by the shape parameter:

full
Returns the full two-dimensional convolution (default).
same
Returns the central part of the convolution of the same size as A.
valid
Returns only those parts of the convolution that are computed without the zero-padded edges. Using this option, C has size [ma-mb+1,na-nb+1] when size(A) > size(B).

Examples

In image processing, the Sobel edge finding operation is a two-dimensional convolution of an input array with the special matrix

These commands extract the horizontal edges from a raised pedestal:

These commands display first the vertical edges of A, then both horizontal and vertical edges.

See Also

conv, convn, filter2

xcorr2 in the Signal Processing Toolbox


 conv convhull