CS6825: Computer Vision word cloud

"Area" based Image Processing Alogrithms

(Spatial Filtering)

The next kind of Image Processing Algorithms, involves looking at a neighborhood of a pixel and using the neighboring pixel values to alter its value. This kind of algorithm can be thought of as an Area Processing Algorithm. Another name for it is Spatial Filtering.

There are many examples of filters or area-based algorithms in existence and each can be used for different purposes. Besides how you combine or use the neigboring pixel values, the size of the neighborhood that is used is varried amoung these algorithms. We discuss below some of the algorithms.... This is not a substitution for class lecture or reading


The Linear Filter a Specific Case of the Area-Based Algorithm

To say that an algorithm is area-based means that the pixels in the surrounding neighborhood may be combined in any number of ways e.g. via multiplication, division, addition, etc. However, to say that you are applying a spatial filter is a more constrained case of the area-based algorithm. Suppose that we will use a 3x3 neighborhood surrounding a pixel. Then we can describe a filter by a mask that contains a weighting factor at each pixel location as follows:

W1 W2 W3
W4 W5 W6
W7 W8 W9

 

Where the pixel under consideration is at the center of the 3x3 window above and is hence assigned the weight W5. The new pixel value is equal to:
Pnew[r,c] = A * {  W1*P[r-1,c-1] + W2*P[r-1,c] + W3*P[r-1,c+1] +

                   W4*P[r,c-1]   + W5*P[r,c]   + W6*P[r,c+1]   +

                   W7*P[r+1,c-1] + W8*P[r+1,c] + W9*P[r+1,c+1    }

where A is some constant (and typically is 1/#pixels in the neighborhood).


The Non-Linear Filter

While the non-linear filter also operates on a neigborhood surrounding the pixel in question, it does not do so based on a mask. Some examples are the Maximum filter that simply chooses the brightest pixel in the neighborhood. Other examples are Minimum, and Median Filters.


Lowpass Filter

This is an example of a Linear Filter and another name for it is a smoothing filter. Some kind of averaging takes place with the mask, where the Wi's are positive values. In the most typical case, the weights are all equal to 1 and the constant A above in the 3x3 case is 1/9. The following is the algorithm to implement this simple smoothing operation. The process of moving and applying the mask to each pixel location is known as Convolution and we say we are convolving with a mask (sometimes also called a kernel).
for(r=0; r<M; r++)

for(c=0; c<N; c++)

{

  Pnew[r,c] = (P[r-1,c-1] + P[r-1,c] + P[r-1,c+1] +

               P[r,c-1]   + P[r,c]   + P[r,c+1]   +

               P[r+1,c-1] + P[r+1,c] + P[r+1,c+1]   )/ 9;

}

Consider the following:
  • What other masks could you think of applying?
  • What would happen if the neighborhood was larger?
  • What would happen if you kept smoothing the image repeatedly?



Median Filter

This is an example of Non-linear filtering. If the objective is to remove noise and to not blurr the image, this approach may be succesful. The operation is to examine the neighborhood and replace the centeral pixel value with the median of the grey levels.

What is the algorithm to implement this? Write it!

Consider the following:
  • Would this be better at removing noise patterns that have strong, spikelike components or noise that varries little from the pixel values?
  • What would happen if a large neighborhood was used?



Highpass Filter

This is a filter that in some sense does the opposite of the Lowpass Filter, it tries to accentuate the higher frequency information in the image and hence Sharpening it rather than smoothing it. Below is an example of such a filter. You can ofcourse design your own.
-1 -1 -1
-1 8 -1
-1 -1 -1



where A = 1/9


Important Notice that the pixel value itself is given a large positive weight and the surround values a small negative weight. This is equivalent to saying in english:
"I want the pixel value to be essentially retained while also enhancing its difference in value to the values of the surrounding pixels"

Consider the following:
  • What is the algorithm to implement the above mask? Write it!
  • How would you create your own sharpening mask? Do it!



Edge Detection

Horizontal Edge Detection
Prewit Edge Detection


Click Here
© Lynne Grewe