Convolution function

The Convolution function performs filtering on the pixel values in an image, which can be used for sharpening an image, blurring an image, detecting edges within an image, or other kernel-based enhancements.

The inputs for this function are the following:

Convolution filter types

Filters are used to improve the quality of the raster image by eliminating spurious data or enhancing features in the data. These convolution filters are applied on a moving, overlapping kernel (window or neighborhood), such as 3 by 3. Convolution filters work by calculating the pixel value based on the weighting of its neighbors.

There are a number of convolution filter types you can choose within this function. You can also specify a User Defined type and enter your own kernel values.

You can apply a median filter to the image by specifying a weight of 1/9 for a 3 by 3 kernel, thereby giving every pixel in the kernel an equal weight. This filter can be used to smooth an image. There are other kernels that can be used to sharpen or enhance edges. You can combine filters to achieve specific results. For example, you may want to apply a filter that will remove speckle or smooth an image, then apply a filter that will detect edges.

For optimal display results, you may want to apply a histogram stretch to adjust the image's contrast or brightness to help pull out features.

The examples below are applied on one of these two images:

Unfiltered grayscale image
Unfiltered grayscale image
Unfiltered color image
Unfiltered color image

Edge detection filters

Gradient types

Gradient filters can be used for edge detection in 45-degree increments.

Type

Description

Example

Gradient East

A 3 by 3 filter

 1  0  1
 2  0 -2
 1  0 -1

Gradient East result

Gradient North

A 3 by 3 filter

 -1 -2 -1
  0  0  0
  1  2  1

Gradient North result

Gradient North-East

A 3 by 3 filter

 0 -1 -2
 1  0 -1
 2  1  0

Gradient North-East result

Gradient North-West

A 3 by 3 filter

 -2 -1  0
 -1  0  1
  0  1  2

Gradient North-West result

Gradient South

A 3 by 3 filter

  1  2  1
  0  0  0 
 -1 -2 -1

Gradient South result

Gradient West

A 3 by 3 filter

 -1  0  1
 -2  0  2
 -1  0  1

Gradient West result

Laplacian types

Laplacian filters are often used for edge detection. It is often applied to an image that has first been smoothed to reduce its sensitivity to noise.

Type

Description

Example

Laplacian 3x3

A 3 by 3 filter

 0 -1  0
-1  4 -1
 0 -1  0

Laplacian 3x3 result

Laplacian 5x5

A 5 by 5 filter

 0  0 -1  0  0 
 1 -1 -2 -1  0
-1 -2 17 -2 -1
 1 -1 -2 -1  0
 1  0 -1  0  0

Laplacian 5x5 result

Line Detection types

Line detection filters, like the gradient filters, can be used to perform edge detection.

You may get better results if you apply a smoothing algorithm before an edge detection algorithm.

Type

Description

Example

Line Detection Horizontal

A 3 by 3 filter

-1 -1 -1
 2  2  2 
-1 -1 -1

Horizontal line detection result

Line Detection Left Diagonal

A 3 by 3 filter

 2 -1 -1
-1  2 -1
-1 -1  2

Left diagonal line detection result

Line Detection Right Diagonal

A 3 by 3 filter

-1 -1  2 
-1  2 -1
 2 -1 -1

Right diagonal line detection result

Line Detection Vertical

A 3 by 3 filter

-1  0 -1 
-1  2 -1 
-1  2 -1

Vertical line detection result

Sobel types

The Sobel filter is used for edge detection.

Type

Description

Example

Sobel Horizontal

A 3 by 3 filter

-1 -2 -1
 0  0  0
 1  2  1

Sobel horizontal result

Sobel Vertical

A 3 by 3 filter

-1  0  1 
-2  0  2 
-1  0  1

Sobel vertical result

Sharpening and Smoothing filters

Sharpening types

The Sharpening (high-pass) filter accentuates the comparative difference in the values with its neighbors. A high-pass filter calculates the focal sum statistic for each cell of the input using a weighted kernel neighborhood. It brings out the boundaries between features (for example, where a water body meets the forest), thus sharpening edges between objects. The high-pass filter is referred to as an edge enhancement filter. The high-pass filter kernel identifies which cells to use in the neighborhood and how much to weight them (multiply them by).

Type

Description

Example

Sharpen

A 3 by 3 filter

  0    -0.25    0
-0.25    2    -0.25
  0    -0.25    0

Sharpen result

Sharpen II

A 3 by 3 filter

-0.25 -0.25 -0.25 
-0.25    3  -0.25 
-0.25 -0.25 -0.25

Sharpen 2 result

Sharpening 3x3

A high-pass 3 by 3 filter

-1 -1 -1 
-1  9 -1 
-1 -1 -1

Sharpen 3x3 result

Sharpening 5x5

A high-pass 5 by 5 filter

 0 -1 -1 -1  0 
-1  2 -4  2 -1 
-1 -4 13 -4 -1 
-1  2 -4  2 -1
 0 -1 -1 -1  0

Sharpen 5x5 result

Smoothing types

Smoothing (low-pass) filters smooth the data by reducing local variation and removing noise. The low-pass filter calculates the average (mean) value for each neighborhood. The effect is that the high and low values within each neighborhood will be averaged out, reducing the extreme values in the data.

Type

Description

Example

Smooth Arithmetic Mean

A 3 by 3 filter

0.111  0.111  0.111
0.111  0.111  0.111
0.111  0.111  0.111

Smooth arithmetic mean result

Smoothing 3x3

A low-pass 3 by 3 filter

1  2  1
2  4  2
1  2  1

Smoothing 3x3 result

Smoothing 5x5

A low-pass 5 by 5 filter

1  1  1  1  1 
1  4  4  4  1 
1  4 12  4  1 
1  4  4  4  1 
1  1  1  1  1

Smoothing 5x5 result

Other filters

Point spread type

The point spread function portrays the distribution of light from a point source through a lense. This will introduce a slight blurring effect.

Type

Description

Example

Point Spread

A 3 by 3 filter

-0.627  0.352 -0.627
 0.352  2.923  0.352
-0.627  0.352 -0.627

Point spread result

Related Topics

5/18/2014