This week, we will start the so-called local or spatial image filtering operations, which in this case, we will continue our study of image processing operations started in the previous week. This week we have five theoretical parts and at the end of this week, it's expected that you will study how to apply such local filters for image smoothing and image enhancement. Also, how to implement more complex image filtering using Fast Fourier Transform, then how to denoise binary images, and finally how to detect edges in images. Speaking about local filters, I should say that actually, we use such filters when we discussed so-called local binary thresholding operations in which we consider some neighborhood of each pixel. In local filter operations, the pixel of the output image is a function not of one pixel but is a function of the so-called spatial neighborhood of each pixel. In this particular case, for example, you see that we have some input image and we try to analyze the third row and third column pixel with value 96. You see that the output of such operations will depend not only on these pixels with value 96 but its neighbor pixels. For example, here we can see the neighborhood as a square of three by three so we have nine pixels in the function of this local filter will be considered as a function of nine variables. In this case, you see that such filters have much more running time when compared to point-wise operations discussed in the previous week, but also it can help us to implement much more complex filters and much better image processing. Let me discuss the main idea of local filtering by using a more simple example of a one-dimensional signal. We have an input signal, some time series, for example, stock prices and we have some kernel or pattern and we want to find some part of the input signal, which is similar to this particular kernel or pattern. In this case, the convolution and cross-correlation operation may help. They are really similar, but the difference is only in the sign flip, so any convolution operation can be expressed as cross-correlation and vice versa just by rotating the kernel. In this particular case, when we apply such an operation, when we look at the output of this operation, we see that the highest output is obtained, the position when the input signal is close to the kernel. In this case, we can set some threshold that the output of convolution and find all points of the input signal, which are the center of part of time series, which are really similar to the input kernel. In this case, we can find, for example, the days in which the stock market grows from today until tomorrow, and then the day after tomorrow. Let me return back to the two-dimensional case again. This is the equation for cross-correlation or for convolution here and we see that we have an input image. We have some kernel, for example, again here three by three kernel and the output of this cross-correlation will be estimated as the weighted sum of this neighborhood with the weights determined by this kernel. In this case, how to apply such operation to the input image, we use the so-called slideing window approach. We start from the top-left pixel. We find these neighborhoods, which in this particular case will be three by three neighborhood of the top-left pixel. Then we use this equation for computing the output of this linear convolution, and after that, we move to another pixel. For each particular pixel of the input image, we have to implement this operation in such case, for example, here, if we have three by three kernel, then for each input pixel we have to analyze in average nine neighborhood pixels. In this case, for example, in this particular case, such operations is 9 times slower when compared to point-wise operation, but we can take into account some spatial deviation of neighborhood pixels. What is the main application of such approach? One of them is the so-called smoothing and the most simple filter here is the so-called box filter. When you just compute the simple arithmetic mean of the brightness of the neighborhood. This is the simplest box filter in whatever exists. It's created for three by three neighborhoods. You see that the main property of smoothing filters is that the sum of the weights is equal to one. You see that here every weight is equal to one divided by nine. Here is the input image and here is the output of this box filter. For sure this output is not so good when we think about the quality of an image, but in this case, we can remove all noise in the background and we can concentrate on the main properties of the input objects. In many cases of computer vision algorithms, such processing is really helpful. The most important and widely used smoothing operation is the Gaussian filter probably you know it from mathematical statistics or from probability theory that this is a Gaussian function. You see that there is no mean here because the mean of the Gaussian is inside the center of the neighborhood. But there is only one parameter, it's sigma, so it's a standard deviation of Gaussian distribution or something like this. The higher is the sigma, the more is the influence of neighborhood pixels. Let me show you some examples. You see here, the left image. It's an input image and you see three output images for different phases of sigma so we increase sigma and you see in the top-bottom part of each output image the representation of the input filter in the black. You see a black and you see some circle inside it, and you see it when we increase the parameter sigma, then the circle, the radius of the circle is also increased. You see that the output of smoothing began also to lower quality. You see that in the right image. For example, here on the main contours of input objects can be considered and can be processed, but anyway, it's really helpful operations for improving the quality of the output image since it's a Gaussian blur and you will use such filters in many, many applications of computer vision. Let me switch to more complex tasks and to more complex filters in the next video.