# Discuss about the mechanics of filtering in spatial domain. Mention the points to be considered in implementation neighbourhood operations for spatial filtering.

1 day ago

Some neighborhood operations work with the values of the image pixels in the neighborhood and the corresponding values of a subimage that has the same dimensions as the neighborhood.The subimage is called a filter,mask, kernel, template, or window,with the first three terms being the most prevalent terminology.The values in a filter subimage are referred to as coefficients, rather than pixels. The concept of filtering has its roots in the use of the Fourier transform for signal processing in the so-called frequency domain. We use the term spatial filtering to differentiate this type of process from the more traditional frequency domain filtering.

The mechanics of spatial filtering are illustrated in Fig.9.1. The process consists simply   of moving the filter mask from point to point in an image. At each point (x, y), the response of the filter at that point is calculated using a predefined relationship.   The response is given by a sum of products of the filter coefficients and the corresponding image pixels in the area spanned by the filter mask. For the 3 x 3 mask shown in Fig. 9.1, the result (or response), R, of linear filtering with the filter mask at a point (x, y) in the image is which we see is the sum of products of the mask coefficients with the corresponding pixels

directly under the mask. Note in particular that the coefficient w(0, 0) coincides with image

value f(x, y), indicating that the mask is centered at (x, y) when the computation of the sum of products takes place. For a mask of size m x n,we assume that m=2a+1 and n=2b+1,where a and b are nonnegative integers ### Fig.9.1 The mechanics of spatial filtering. The magnified drawing   shows a 3X3 mask and the image section directly under it; the image section is shown displaced out from under the mask for ease of readability.

In general, linear filtering of an image f of size M x N with a filter mask of size m x n is given by the expression: where, from the previous paragraph, a=(m-1)/2 and b=(n-1)/2. To generate a complete filtered image this equation must be applied for x=0,1,2,……, M-1 and y=0,1,2,……, N-1. In this way, we are assured that the mask processes all pixels in the image. It is easily verified when m=n=3 that this expression reduces to the example given in the previous paragraph.

The process of linear filtering is similar to a frequency domain concept called convolution. For this  reason,  linear  spatial  filtering  often  is  referred  to  as  ―convolving  a  mask  with  an  image.‖ Similarly, filter masks are sometimes called   convolution   masks. The term convolution kernel also is in common use. When interest lies on the response, R, of an m x n mask at any point (x,y), and not on the mechanics of implementing mask convolution, it is common practice to simplify the notation by using the following expression: where the w’s are mask coefficients, the z’s are the values of the image graylevels corresponding to those coefficients, and mn is the total number of coefficients in the mask. For the 3 x 3 general mask shown in Fig.9.2 the response at any point (x, y) in the image is given by  