Primary Convolutions In Image Processing
Article 2
As discussed in the article 1, (If you missed it you can quickly go and see it here https://medium.com/@madarapremawardana/primary-convolutions-in-image-processing-b64917c9da80 ) here we’ll go with the linear, mean and mode filters.
In image processing filters are mainly used to suppress
- High frequencies in the image — Smoothing images removing roughness or edgy-ness.
- Low frequencies — Enhancing or detecting edges in the image
There are basically two types of filters as Low pass filters (smoothing) and moving window operations. Low pass filters remove high spatial frequency noise from a digital image ad Moving window operations affects one pixel of the image at a time, changing its value by some function of a “local” region of pixels. (“covered” by the window).
- Low pass filters — Reconstruction filtering, Enhancement filtering
- Moving window operations — Neighborhood-averaging filters, median filters, Mode filters
Linear Filtering
Neighborhood-averaging filters
Replace the value of each pixel, a[i,j] say, by a weighted average of the pixels in some neighborhood around it. (i.e.: a weighted sum of a[i+p,j+q], with p = -k to k, q = -k to k for some positive k; the weights are non-negative with the highest weight on the p = q = 0 term. If all the weights are equal then this is a mean filter is “linear”)
Median Filters
Replaces each pixel value by the median of its neighbors. (i.e. the value such that 50% of the values in the neighborhood are above, and 50% are below. )
Mode filters
Each pixel value is replaced by its most common neighbor. This is a particularly useful filter for classification procedures where each pixel corresponds to an object which must be placed into a class.
Mean Filtering (AKA Neighborhood Averaging)
The idea of mean filtering is simply to replace each pixel value in an image with the mean (‘average’) value of its neighbors, including itself. This has effect of eliminating pixel values which are unrepresentative of their surroundings.
Let f(x,y) is a noisy image then the smoothed image
g(x,y) can be obtained by
Where S is a neighborhood of (x,y) and n is the number of pixels in S.
sized Filters
Results of Mean Filtering with a mask of size nxn n=3,5,7,15,25
Some problems with Mean Filtering
Mean Filtering tends to blur to the image and hence the sharpness of edges may be reduced.
Example:
Median Filtering
In Median Filtering, pixel values are replaced by the median value of their neighborhood.
Example:
The shaded pixel will be replaced by the median of its 3x3
Neighborhood :37, 37, 39, 40, 41, 41, 42, 42, 43 Which is 41.
Notes
Median filtering has the following properties
1. Reduces the variance of the intensities in the image.
2. Intensity oscillations with a period less than the window width are smoothed.
3. Preserves the sharpness and location of edges.
Mode Filtering
Mode filtering involves assigning to the central pixel the most common value inside the local window around the pixel.
That is the mode of the histogram of local values.
Example:
The shaded pixel will be replaced by the mode of its 3x3
Neighborhood: 42, 37, 37, 39, 40, 41, 41, 42, 42
Which is 42.