Signal processing accompanies us every day. All stimuli (signals) received from the world around i.e. sound, light or temperature are processed into electrical signals, which are later sent to the brain. In the brain the analysis and interpretation of the received signal takes place, as a result of which we get information from the signal (e.g. we can recognize the shape of an object, we feel the heat, etc.).

 

Digital signal processing (DSP) works in a similar way. In this case, the analog signal is converted into a digital signal by an analog-digital converter. Then, using the digital computer, received signals are being processed. The DSP systems also use computer peripheral devices equipped with signal processors which allow to process signals in real time. Sometimes it is necessary to re-convert the signal to an analog form (e.g. in order to control of a device). For this purpose, digital-to-analog converters are used.

 

Digital signal processing has a wide range of applications. It can be used to process sound, for speech recognition or for image processing. The last issue will be the subject of this article and we will deeply discuss the basic operation of convolutional filtration  in digital image processing.


Image processing


Simply speaking, digital image processing consist in transforming the input image into an output image. The aim of this process is to select information – choosing the most important (e.g. shape) and eliminating unnecessary (e.g. noise). Digital image process features a variety of different image operations such as:

  • filtration,
  • thresholding,
  • segmentation,
  • geometry transformation,
  • coding,
  • compression.
  As we mentioned before, in this article we will focus on image filtration.

Convolutional filtration


Both in one-dimensional domain (for audio signals)  and also for two-dimensions, there are specific tools for performing operation on signals – in this case on images. One of such tools is filtration. It consist in some mathematical operations on pixels which as a result give us a new image. Filtration is commonly used to improve image quality or to extract important features from the image.

 

The basic operation in filtration method is the 2D convolutional function. It allows to apply image transformations using appropriate filters in a form of matrix coefficients. The use of filters consist in calculating point’s new value based on the brightness values of points in the closest neighborhood. The so-called masks containing pixel weights based on the closest pixels values are used in calculations. The most common sizes of masks are 3×3, 5×5 and 7×7. The process of image and filter convolution has been shown below.

 

Assuming that the image is represented by a 5×5 matrix which contains color values and the filter represented by a 3×3 matrix, the image was modified by joining these matrices.

 

The first thing to do is to transpose coefficients in a filter. We assume that the center of the filtration core h(0,0) is in the middle of the matrix, as shown in the picture below. Therefore (m,n) indexes denoting rows and columns of the filter matrix will be both negative and positive.



Considering the filter matrix (blue one) as inverted vertically and horizontally we can perform filtration operations. They start by placing the h(0,0) → h(m,n) element of the blue matrix over the s(-2,-2) → s(i,j) element of the yellow matrix (the image). Then we multiply the overlapping values of both matrices and add them up. In this way we have obtained the convolution result for (-2,-2) cell of the output image. It is important to remember about the normalization process, which allows us to adjust the brightness a result by dividing it by the sum of filter coefficients. It prevents the output image brightness from being out of scale of 0-255 (in case of 8-bit image representation).

 

The next stages of this process are very similar – we move the center of the blue matrix over the (-2,-1) cell, then again multiply the overlapping values, add them together and divide the result by the filter coefficients to get the result. We consider cells that go beyond the area of the matrix s (i,j) to be undefined, therefore the values do not exist in these places, so we do not multiply them.


The usage of convolutional filtration


Depending on the type of filter we can distinguish a number of applications of convolutional filtration. Low-pass filters are used to remove noise from images, while high-pass filters are used to sharpen or emphasize edges. In order to illustrate the effects of different filters, we will apply them on real image. The picture below is a “jpg” format and was loaded in Octave software as an MxNx3 pixel matrix.



Gaussian blur


To blur the image we need to use convolutional function as well as properly prepared filter. One of the most commonly used low-pass filter is the gaussian filter. It allows you to lower the sharpness of the image but also it is used to reduce the noise from it.

 

For the purpose of this article a 29×29 matrix based on Gaussian function with a standard deviation of 5 was generated. Normal distribution gives weights to the surrounding pixels during the process of convolution. Low-pass filter suppresses high-frequency image elements while passing low-frequency elements. The output image compared to the original one is blurry, and the noises are significantly reduced.



Sharpen


We can make the image blurry but there is also a way to make it sharpen. To make it happen a suitable high-pass filter should be used. The filter passes through and amplifies image elements that are characterized by high frequency e.g. noised or edges. However, low frequency elements are suppressed. By using this filter the original image is sharpened – it can be easily noticed especially in the arm area.



Edges detection


Another possible image process is called edge detection. Shifting and subtracting filters are used to detect edges on the image. They work by shifting the image and subtracting the original image from its copy. As a result of this procedure, edges are being detected, as show in the picture below.



BFirst.Tech experience with image processing


Our company hires well-qualified staff with experience in a field of image processing. One of our original projects called TIRS, i.e. a platform which diagnoses areas in human body which might be affected by cancerous cells, works based on the use of advanced image processing algorithms and artificial intelligence. It allows to automatically detect cancerous areas with the use of medical imaging data obtained from tomography and magnetic resonance imaging. This platform finds its use in clinics and hospitals.

 

Our another project, which also required the usage of image processing, is called Virdiamed platform. It was created in cooperation with Rehasport Clinic. This platform allows a 3D reconstruction of CT and MRI data, and also viewing 3D data in a web browser.

 

Digital signal processing, including image processing, is a field of technology with wide range of application possibilities, and its popularity is constantly growing.  Non-stopping technological progress means that this field of technology is also constantly developing. Many technologies used every day are based on signal processing, which is why it is certain that in the future the importance of DSP will continue to grow.


Sources:

[1] Leonowicz Z.: “Praktyczna realizacja systemów DSP”

[2] http://www.algorytm.org/przetwarzanie-obrazow/filtrowanie-obrazow.html

[3] https://docplayer.pl/106379955-Filtracja-splotowa-obrazu.html