 Sudhakar Barbade, assistant professor, electronics and communication engineering, Valchand Institute of Technology, Solapur. Today, we will discuss smoothing using spatial filtering, learning outcome. At the end of this session, students will be able to apply image smoothing algorithms in spatial domain for image enhancement. In this session, we will discuss neighborhood operations, spatial filtering, smoothing operations. First, we will see neighborhood operations. Neighborhood operations simply operate on larger neighborhood of pixels than point operations. Here, we can look at the sample image at the right side, image having y rows and x columns and the neighborhood operation taken is here 3 by 3. Neighborhoods are generally a square matrix of odd size called filter mask and mostly 3 by 3 square matrix is used for filter mask. Neighborhood operations. Some simple neighborhood operations also called ordered statistics non-linear filters include mean which sets the pixel value to the minimum in the neighborhood, max which sets the pixel value to the maximum in the neighborhood and median which sets the numbers as the midpoint value in that set. Example here is given. Suppose, it is a matrix containing 1, 7, 15, 18 and 24 pixels, value of the pixels. Then median of this will be midpoint in the range that is called 50. Neighborhood operations, we are going to continue. The neighborhood operation on the whole image is given by this algorithm where the first step is move the reference point that is center of the mask to the origin of image, apply the given neighborhood operation on pixels inside some image under the mask, then store the result at the reference point pixel of the output image, move the mask to the next location and go to step 2 so that all pixels in the image are covered. Now, there is a time for think and write. Here you apply max neighborhood operation on the following image at center pixel value of 2 by 2 and find new pixel value. Here for applying use 3 by 3 matrix where center pixel is 2. That means filter mask consists of 2, 4, 1, 9, 2, 3, 7, 2, 9 from the origin. The answer is the maximum value of the pixel in the 3 by 3 neighborhood is 9. That is why the center pixel value 2 will be replaced by 9 and this is called max neighborhood operation. Similarly, we can apply the other algorithms. Now, next is spatial filtering process. What happens in spatial filtering? Just we will look at again the same image having y rows and x columns where image f of x y is the input image and the center pixel is named as e. Then there is a neighborhood of simple 3 by 3 matrix. Then we can name those neighboring pixels as a, b, c, d, f, g, h, i. These are the original image pixels in the image and 3 by 3 filter is overlapped on the center of the original image and these are named as pixels r, s, t, u, v, w, x, y, z. Now, how filtering or spatial filtering process happens that is given by this formula. The new center pixel value processed is equal to v multiplied by e corresponding pixels of filter mask and the original image pixels were multiplied and added together. This gives us the new value of original pixel at the center. The above process is repeated for every pixel in the original image. Now, we will see the first smoothing spatial filters. One of the simplest spatial filtering operations we can perform is smoothing operation. Here simply average all of the pixels in a neighborhood and around the center value especially useful in removing noise from the images. Also useful for highlighting gross details. The filter mask is given which is called simple averaging filter. Each element in the matrix consists of 1 by 9 and the corresponding pixels in the original image are multiplied and added. So, we get finally the average of all 9 values which will be the new value at the center pixel. Let us see how it works. These are the image values, sample image values we have taken of size 3 by 3. Then we are multiplying with the filter mask of simple averaging that is contains 1 by 9. So, how the calculation is done is like this corresponding pixels of original image and filter mask are multiplied and added together. So, the new value at the place of 106 will be the 98.33 as an average value in that neighborhood. The above process is repeated for every pixel in the original image to generate the smoothly image. So, this process is repeated. Image smoothing example here on the right side top left figure is a original image and of size say 500 by 500 pixels and the subsequent images show the image after filtering with an averaging filter of increasing sizes. Size is 3 by 3, 5 by 5, 9 by 9, 15 by 15 and 35 by 35. So, all size of the filter and we see that as the filter mask size increases we get blurring operation. The image is too smooth. So, you should take care of the size of the filter mask also. If the original image is more blurred then we can go for higher filter mask values size otherwise there is no need 3 by 3 will work. Most effective smoothing filters can be generated by allowing different pixels in the neighborhood with different weights in the averaging filter. This filter is called weighted averaging filter. Here pixels closer to the center pixel are more important. That is why the weight assigned here is 4 whereas the weight assigned to the right is 2, left is 2, top is 2, bottom is 2. Whereas diagonally the weight is the smallest that is 1 often referred to as a weighted averaging. If we apply this filter and median filter on the original image shown to the left filtering is often used to remove noise from images. And sometimes we find that median filter works better than the averaging filter. If you look at the image in the middle that is the image after averaging filter and to the right side image after median filter. So, we observe that median filter produces a good result. In summary we have looked at neighborhood operations, spatial filtering and in that smoothing operations. References Digital image processing by Rafael C. Gonzalez and Richard Woods from Tata McGraw-Hill Education