Image Processing Toolbox    
conv2

Perform two-dimensional convolution

Syntax

Description

C = conv2(A,B) performs the two-dimensional convolution of matrices A and B, returning the result in the output matrix C. The size in each dimension of C is equal to the sum of the corresponding dimensions of the input matrices minus one. That is, if the size of A is [ma,mb] 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 are both vectors.

C = conv2(...,shape) returns a subsection of the two-dimensional convolution, as specified by the shape parameter. shape is a string with one of these values:

For image filtering, A should be the image matrix and B should be the filter (convolution kernel) if the shape parameter is 'same' or 'valid'. If the shape parameter is 'full', the order does not matter, because full convolution is commutative.

Class Support

All vector and matrix inputs to conv2 can be of class double or of any integer class. The output matrix C is of class double.

Remarks

conv2 is a function in MATLAB.

Example

See Also

xcorr, xcorr2 in the Signal Processing Toolbox User's Guide

conv, deconv in the MATLAB Function Reference


 colorbar convmtx2