I just want to ask if there are resources you recommend that describe Image smoothing
simply.
Thanks.
Color image smoothing is part of preprocessing techniques intended for removing possible image perturbations without losing image information. Analogously, sharpening is a pre-processing technique that plays an important role for feature extraction in image processing.
Mean filtering is a simple method of smoothing and diminishing noise in images by eliminating pixel values that are unrepresentative of their surroundings. The idea of mean filtering is to replace each pixel value in an image with the mean or average value of its neighbors, including itself.
Smoothing is usually done to help us better see patterns, trends for example, in time series. Generally smooth out the irregular roughness to see a clearer signal. For seasonal data, we might smooth out the seasonality so that we can identify the trend.
A smoothing filter passes low frequencies and attenuates high frequencies. From: Environmental Data Analysis with MatLab, 2012.
Like some of the commenters mentioned, image smoothing can mean a lot of things. Mainly though, when someone uses the term they mean blurring or low-pass filtering. These are usually used synonymously. Idea of blurring is intuitive to us as visual beings, but what does it really mean?
When using a camera lens out of focus it means that rays of light reflected from objects mix in our vision. This is an image representing focused vision:
Here's a similar diagram representing blurred or non-focused vision:
In order to reproduce this effect digitally, let's take every pixel of an image and replace it by an average of itself and its neighboring eight pixels:
Above is an image of a single white pixel inside a 7x7 black square. Note that it’s a single white pixel, not a whole square of pixels, just very up blown up. In a standard 8-bit image representation, this is represented as the following
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
When we perform averaging, that is replacing each pixel with the average of all pixels in a 3x3 square around it (that includes the original pixel also, we get
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 28 28 28 0 0 0 0 28 28 28 0 0 0 0 28 28 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Above numbers are integers, because so far we’ve only done integer operations, so let’s be consistent.
This may not look like much of a smoothing for now, but let’s look at another example. Below is a checkerboard image with altering 0 and 255 pixel values.
Let’s now replace each pixel by an average of a 4x4 square where the original pixel is positioned as such:
. . . . . X . . . . . . . . . .
Your see that because of the checkerboard pattern, the average value of each such square will be 255/2 = 127 (integer division again). The checkerboard pixel alterations are very drastic from pixel to pixel. Going from any pixel to its neighbor, we go from highest possible pixel value to the lowest possible one. This is known as high frequency content. When averaging, we remove this high frequency component, and therefore, in signal processing lingo, we’re performing high stop filtering or, synonymously, low pass filtering. Don’t worry about strange artifacts on the edges. They are there because when filtering on the edge of the image, we’re missing pixels to average over, so we assume everything beyond the image is just black.
Let’s perform the same kind of averaging on a regular grayscale image. Below is the famous Lenna image. Next to it is its averaged version using a 7x7 averaging mask. You can see that it’s smoothed or blurred.
This was a very simplistic example of image smoothing via averaging. Averaging is only one special case of low-pass filtering. In general, we perform weighted averaging to achieve desired low-pass filter effects. For further reading, I suggest looking up filter theory and convolution.
I hope this helps.
Image Smoothing
is usually synonymous with Low Pass Filtering
or getting rid of the high frequencies
.
Background - what is filtering:
Most people understand what filtering is intuitively. You take something and pass it through a filter and remove something and the output doesn't have the substance that you filtered out. In images/2d and 1d signals you can filter.
The way you implement filtering on a 2d or 1d image is to do a convolution of the input, x, and the filter, h, to create the output y.
Here is an example of convolution in the 1d that I wrote in 5 minutes and did not check for errors:
void conv(float *x, int x_len, float * h, int h_len, float * y, int y_len)
{
int i;
register double accum;
for(i = 0; i < x_len-h_len-1; i++) {
accum = 0;
for(j = 0; j < h_len; j++) {
accum += x[i+j] * h[j];
}
y[i] = accum;
}
}
int main {
float x[] = {...};
int x_len = sizeof(x)/sizeof(x[0]);
float h[] = {...};
int h_len = sizeof(h)/sizeof(h[0]);
float y[x_len-h_len-1] = {0};
int y_len = x_len-h_len-1;
conv(x,x_len,h,h_len,y,y_len);
}
Notice how the input signal x is filtered by h. Then the output is stored in y. For more info search convolution on google.
Low pass filtering:
Now that you know how to filter a 1d signal. You can do a low pass filter. To do a low pass filter you create a filter h that only lets the low frequencies through. The most simple low pass filter is a rectangle filter h = ones(1,N); h = h ./ N;
(matlab code). A more complex filter is a gaussian filter (this is very commonly used in image processing. See Photoshop/Gimp and look for "gaussian blur"). There are infinitely ways to create a low pass filter.
To create a custom low pass filter use the Parks-McClellan_filter_design_algorithm to create a arbitrary specific low pass filter. For more information search google for "creating a low pass filter".
Finally to answer your question - Image smoothing:
To do image smoothing you do the same thing in 1d but everytime you see a single for loop you have a double for loop (because you are doing a 2d signal).
Creating the filter is also similar but instead of having a 1d array filter, h, your filter h is now two dimensional.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With