Signal Processing Toolbox    
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.

Each dimension of the output matrix C is equal in size to one less than the sum of the corresponding dimensions of the input matrices. When [ma,na] = size(A) and [mb,nb] = size(B),

C = conv2(A,B,'shape') returns a subsection of the two-dimensional convolution with size specified by 'shape', where:

conv2 executes most quickly when size(A) > size(B).

The conv2 function is part of the standard MATLAB language.

Examples

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

Given any image, the following code extracts the horizontal edges.

The following code extracts the vertical edges first, and then extracts both horizontal and vertical edges combined.

See Also
conv
Convolution and polynomial multiplication.
convn
N-dimensional convolution (see the MATLAB documentation).
deconv
Deconvolution and polynomial division.
filter2
Apply a two-dimensional filter to data.
xcorr
Cross-correlation function estimate.
xcorr2
Two-dimensional cross-correlation.


 conv convmtx