Specifications

Image Filtering
6-3
6
2D Convolution
The 2D convolution is a versatile image processing primitive which can be
used in a variety of image processing operations; for example, edge
detection, blurring, noise removal, and feature detection. It is also known
as mask convolution or spatial convolution.
NOTE. In some literature sources, the 2D convolution is referred to as
box filtering, which is an incorrect use of the term. A box filter is a linear
averaging filter (see function
iplBlur above). Technically, a box filter
can be effectively (although less efficiently) implemented by 2D
convolution using a kernel with unit or constant values.
For 2D convolution, a rectangular kernel is used. The kernel is a matrix of
signed integers or single-precision real values. The kernel could be a single
row (a row filter) or a single column (a column filter) or composed of
many rows and columns. There is a cell in the kernel called the “anchor,”
which is usually a geometric center of the kernel, but can be skewed with
respect to the geometric center.
For each input pixel, the kernel is placed on the image such that the anchor
coincides with the input pixel. The output pixel value is computed as
y
m,n
=
Σ
i
Σ
k
h
i,k
x
m
-
i,n
-
k
where x
m
-
i,n
-
k
is the input pixel value and h
i,k
denotes the kernel. Optionally,
the output pixel value may be scaled.
The convolution function can be used in two ways. The first way uses a
single kernel for convolution. The second way uses multiple kernels and
allows the specification of a method to combine the results of convolution
with each kernel. This enables efficient implementation of multiple kernels
which eliminates the need of storing the intermediate results when using
each kernel. The functions
iplConvolve2D() and iplConvolve2DFP()
can implement both ways.