What do filters do in Photoshop

Make Photoshop filters yourself (own filters)

Filters are an important part of digital image processing. No graphics program that is not equipped with an abundance of different filters. From simple blurring to artistically elaborate effects, (almost) everything is possible. Most graphics programs allow you to define your own filters and with a little training you can achieve amazing results. But how do image filters actually work? Which basic image properties do you build on and what do you have to pay attention to when creating your own filters?

Linear filters

One of the most important filter classes are linear filters. They are often used to Removal of errors or image noise used. Linear filters are local operations that convert the color and brightness values ​​of the pixels of an initial image into a resulting image. The dependencies of neighboring pixels are used here. Or to put it another way: Adjacent pixels in a natural image are usually dependent on one another and "resemble" one another in terms of color and brightness. Abrupt jumps are either sharp edges and contours or image errors (e.g. noise). By weighting neighboring pixels differently, errors can be reduced, edges and contours smoothed or the image sharpened as a whole.
This is achieved using a weighting matrix, also known as a filter kernel, which gives each pixel a weighting in relation to its neighbors. A mathematical mapping is used to determine a new color value for each pixel in the output image using the weighting matrix. The weighting matrix is ​​shifted point by point over the original image. Only the value of the pixel currently in the center of the matrix is ​​calculated. All pixels under the weighting matrix are multiplied by the individual values ​​of the matrix and the total result is entered as the new color value for the currently calculated pixel.

Filter: Smooth

A wide variety of effects are achieved depending on the weighting of the individual grid points. If, for example, all pixels are weighted equally, this averaging produces a smoothing (soft focus) of the image.

So that the brightness of the resulting image corresponds to the original image, the result must be divided by the sum of the factors in the matrix. In this case 9.

Filter: sharpen

If the central pixel is rated higher than the neighboring pixels, the image sharpness is increased. However, this also increases the noise contained in the image, which is usually undesirable.

Filter: detect edges

In addition to blurring or sharpening images, linear filters can also be used to detect edges and contours. Application scenarios can be found, for example, in medical technology or image recognition control systems. The filter matrix can be derived from the brightness gradients of the image. The brightness gradient is a measure of the change in brightness of neighboring pixels. In other words, when you apply these filters, the following happens:
The row of pixels to the left and right (or above and below) of the current position is considered. If the pixel values ​​are the same, the sum is 0 due to the different signs, there is no edge. If the pixel values ​​are different, the result is a sum> 0, there is an edge.

Horizontal edge filter:

Vertical edge filter:

Create your own filters with Photoshop

Photoshop offers the possibility own filters using a filter matrix. This is great for experimenting with. The function can be found in the menu: Filter-> other filters-> own filter.
An input area of ​​5 × 5 fields is available to define the filter matrix. The value for scaling the results is entered in the “Scaling” field. The result is divided by this value.
The “Offset” field adds a fixed value to the final result and corresponds to a shift in the entire color range.
The input of the smoothing matrix described above would look like this, for example:

All 25 values ​​of the matrix can be filled in to reinforce the effect. The scaling factor must then be correspondingly larger.

An edge filter can also be implemented without any problems. The result is particularly clear with images with clear edges:

By combining different weighting factors, scaling and offset, amazing effects can be achieved:

Have fun experimenting 🙂