Image Processing Toolbox | ![]() ![]() |
Higher-Dimensional Convolution
To perform two-dimensional convolution, you use conv2
or filter2
. To perform higher-dimensional convolution, you use the convn
function. convn
takes as arguments a data array and a convolution kernel, both of which can be of any dimension, and returns an array whose dimension is the higher of the two input arrays' dimensions. convn
also takes a shape parameter argument that accepts the same values as in conv2
and filter2
, and which has analogous effects in higher dimensions.
One important application for the convn
function is to filter image arrays that have multiple planes or frames. For example, suppose you have an array A
containing five RGB images that you want to filter using a two-dimensional convolution kernel k
. The image array is a four-dimensional array of size m
-by-n
-by-3-by-5. To filter this array with conv2
, you would need to call the function 15 times, once for each combination of planes and frames, and assemble the results into a four-dimensional array. Using convn
, you can filter the array in a single call.
B = convn(A,k);
For more information, see convn
in the MATLAB Function Reference.
![]() | Separability | Using Predefined Filter Types | ![]() |