|
||||||||||||||||||||||||||||
"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.... The Linear Filter a Specific Case of the Area-Based AlgorithmTo 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:
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 FilterWhile 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 Filterfor(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:
Median FilterWhat is the algorithm to implement this? Write it! Consider the following:
Highpass Filter
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:
Edge DetectionClick Here |
||||||||||||||||||||||||||||
© Lynne Grewe |