Signal Processing Toolbox Help Desk

conv2

Purpose

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 the sum of the corresponding dimensions of the input matrices minus 1. For [ma,na] = size(A) and [mb,nb] = size(B), then size(C) = [ma+mb-1,na+nb-1].

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).

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 line extracts the horizontal edges:

The lines below extract first the vertical edges, then both horizontal and vertical edges combined:

See Also

conv

Convolution and polynomial multiplication.

convn

N-dimensional convolution (see MATLAB Function Reference).

deconv

Deconvolution and polynomial division.

filter2

Two-dimensional digital filtering.

xcorr

Cross-correlation function estimate.

xcorr2

Two-dimensional cross-correlation.



[ Previous | Help Desk | Next ]