todo: separate them into multiple files Image filtering means applying some function to a part or to the entire image.

Image filtering is used for numerous purposes, such as noise reduction, filling in missing information, or extracting image features.

When an image is filtered, the noise may be reduced and so it’s easier to extract useful information, such as known patterns.

Linear Filtering

The simplest filtering is linear filtering, consisting in replacing each pixel with a linear combination of its neighbors. This can be achieved with an operation called convolution.

Convolution

Let be the discrete image represented by a matrix Let be the filter “kernel”

The filtered image is the result of the convolution between the Image and the Kernel.

is the same to applying with the mirrored filter.

Schermata 2022-09-09 alle 15.31.05.png

We can also have a one dimension filtering, meaning it will be represented as .

Note

Basic properties of Linear Systems

  • Homogeneity:
  • Additivity:
  • Superposition:
  • Linear systems Superposition

Filtering to Reduce Noise

Noise is something that we’re not interested in. Is defined as low-level noise the fluctuations of the light, the sensor noise, quantization effects, etc.

Complex noise instead is, for example, shadows and extraneous objects.

Additive Noise

Additive noise is a model that recreates an image applying the following formula: where and are respectively the Signal, the Noise, and the Image.

Note that the noise doesn’t depend on the signal.

Average Filter

This type of filter works by replacing each pixel with an average of its neighbours.

Average filters are useful to reduce the noise of an image since averaging an area (smoothing it) makes it more homogeneous.

When smoothing a little bit of signal (information contained inside the image) is lost. The more the image is noisy, the more smoothing is needed.

Box filter

The simplest of these types of filters weights all the neighbours in the same way.

All the values in the kernel have the same value and add up to 1. An example of a kernel is

Gaussian filter

Different from the box filter, this type of filtering weights the nearest neighbours more than the distant ones.

The kernel depends on the (standard deviation) value, but its central values are bigger than the values on the borders. An example is

Smoothing an image with a Gaussian filter instead of a Box filter makes the general details of the image more visible, when smoothing an area weighting all the pixels, in the same way, may lose some details.

When the is larger, the kernel gets larger and the image is smoother, and vice versa otherwise.

The Gaussian distribution in 2D is represented by the following equation

The Gaussian distribution in 1D is represented by this equation

Differences between Gaussian and Box filtering

Differences between Gaussian and Box filtering

Separability principle

Both the Box filter and the Gaussian filter are separable, meaning they can be written as the product of two or more simple (lower dimension) filters.

This is an example of the separation of a 2D Box filter.

As the demonstration shows, generally a filter is separable if you can factorize its equation, which depends on and , into two other equations that depend on one by and one by .

The convolution of two 1D filter is more efficient than a single convolution with a 2D filter.

Sharpening

Sharpening filtering can be achieved by doubling all the values of the image matrix and subtracting from it the blurred image. The blurring can be achieved with any smoothing filter such as box or gaussian.

A sharpened photo enhances the changes in the color intensity.

An example of sharpening

An example of sharpening


tags: signal-processing machine-learning