JMU
Convolutions for Image Processing
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu


Introduction
The Kernel as a Grid/Matrix

images/source-destination-images.gif

images/kernel.gif

images/spatial_convolution.gif

A Formal Definition

Letting \(s_{i,j}\) denote the value in source pixel \((i,j)\), \(k_{r,c}\) denote the value in element \((r, c)\) of the kernel, and \(d_{i,j}\) denote the value in destination pixel \((i, j)\), a 3x3 spatial convolution can be defined as follows:

\( d_{i,j} = \sum_{r=-1}^{1} \sum_{c=-1}^{1} s_{i+r, j+c} k_{r,c} \)

An Example

The Source
images/spatial_convolution_source.gif

The Kernel
images/spatial_convolution_kernel.gif

The Convolution
images/spatial_convolution_destination1.gif
images/spatial_convolution_destination2.gif
images/spatial_convolution_destination3.gif
images/spatial_convolution_destination4.gif

The Identify Kernel

0 0 0
0 1 0
0 0 0

A Blurring Kernel
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
A Blurring Kernel (cont.)
images/spatial_convolution_blur.gif
An Edge-Detection Kernel
\( 0-1 0 -1 4-1 0-1 0 \)
A Sharpening Kernel
  1. Find the edges (i.e., start with an edge detection kernel)
  2. Add the edges to the original image (i.e., add an identity kernel)
1 -1 0
-1 5 -1
0 -1 1