Convolve Filters

What is a Convolution?

A convolution is one of the convex folds of the surface of the brain, and you may feel like your brain is all crinkled up by convolutions, but they are quite useful.

A convolution is an image processing operation that operates by comparing neighboring pixels.  Convolution filters are often encapsulated into one simple to use model called a convolution kernel that can perform a number of different functions that simulate real world effects.

 

A convolution kernel is nothing more complex than a set of values that are used to blend neighboring pixels.  The group is organized into a rectangle, here with 3 rows and 3 columns.

The center value represents the center pixel, and the value it will be multiplied by.  Each surrounding pixel is also multiplied by a value, and then all the pixels are added together.  To 'normalize' , or to keep the final value within a usable range, it is then divided by the sum of all the values.  The convolution kernel filter shown here automatically calculates the sum for us.  As an option, an 'offset' value can be added.  It is useful for certain times, such as when you want to have an image based around gray.

There are numerous effects that can be achieved with a convolution kernel.  Included are blur, sharpen, edge detect, emboss, and more.  Here are just a few examples:

1

1

1

 

-1

-1

0

 

1

1

1

1

1

1

-1

0

1

1

-8

1

1

1

1

0

1

1

1

1

1

Blur (box filter)

 

Emboss

 

Edge detect


 

Gray emboss

Imparts the impression of a stone carving or chiseled look to an image..


 

Color emboss

Embosses an image as if part of it was raised, and part recessed.


 

Edge detect

The edge detect filter determines the edges of items in an image and gives them a solid outline similar to a pencil drawing.


 

Sobel edge detect

This edge detection algorithm uses two successive convolution kernels and a Gaussian blur to determine the edges in an image, so it is smoother and more accurate than a typical edge detection. Technically, it is the absolute value of the gradient of the value of an image. In other words, it represents a literal interpretation of the contour in the image, if the image were a height map. The output image best describes the outline of the contour of the image.



 

Color Sobel

A color version of the Sobel algorithm


 

Maximize

The maximize filter spatially expands the lightest areas in an image. In other words, if a pixel is lighter than its surrounding pixels, the surrounding pixels will become that lighter color.


 

Median

The median filter spatially expands the average color in an image. In other words, the filter compares 8 neighboring pixels, sorts them by value, and takes the middle value. That color is then spilled into the neighboring pixels.

This filter is useful for removing isolated noisy pixels from an image or for removing noise in general.  Multiple applications can also impart a painterly quality.


 

Minimize

Minimize spatially expands areas of darkness in an image. In other words, if a pixel is darker than its surrounding pixels, the surrounding pixels will become that darker color.

It might be used several times to create a painting like effect.


 

MaxMin

MaxMin is useful for removing isolated dark pixels from a light background.

It simply performs a maximize, then a minimize filter.


 

Minmax

MinMax is useful for removing isolated bright pixels from a dark background.

It simply performs a minimize, then a maximize filter.


 

High Pass


A high pass filter is usually the first step of a sharpening filter. It identifies high frequency detail (passing them through) and eliminates low frequency detail.

It can be used to create custom sharpen filters, where you merge the high-passed image with the original image, perhaps with the “around gray” layer mode.



To the right, the high pass filter is combined with the original image, to create a much sharper image.

Sharpening an image in fact does not increase the detail in the image. It merely increases the contrast in high frequency detail. It can be though of as localized contrast enhancement. That is, in the area surrounding high frequency detail, the darks get darker, and the lights get lighter.

The technique could just as easily be used to reverse the effects of a sharpness filter, by inverting the high-pass image.






Abs

Technically, not a convolution, Abs (Absolute value) is here to support other convolution filters. It can be used in the creation of “edge preserving mattes.”

With this image (right) in the alpha channel, the original image could be blurred, and on the low frequency detail would be blurred. The high frequency detail would remain sharp. This is a great way to reduce noise in an image without making the image blurry.


Original image


High pass filtered


Abs (absolute value) is applied. A level adjustment is also made. This now becomes a reasonable image that can be used as an alpha channel (Selection)






Gradient convolve

This filter detects the gradient (slope) of an image based on lightness. The resultant image can look very similar to an emboss effect, but you have specific control over directionality. What's really happening is the filter is determining slope. An upward slope gets lighter, and a downward slope gets darker.







Adjustable median

This median filter lets you adjust the size of the input window, ie, the number of pixels that are sorted. The middle value of all the pixels is then used for the destination pixel.

A median filter is an edge preserving noise reduction algorithm.

Median filtering can reduce noise, at the risk of the image becoming somewhat blocky or blobby.







Adjustable maximize

The adjustable maximize filter compares the current pixel with a number of neighboring pixels (controlled by Size) and sets the current pixel to the maximum value off all the compared pixels.








Adjustable minimize

The adjustable minimize filter compares the current pixel with a number of neighboring pixels (controlled by Size) and sets the current pixel to the minimum value off all the compared pixels.