Filter: Blur

Source: modified from [PITA00:122-124]

The blur is the easiest of the area filters to understand and implement. Recall that for an area filter, the filtered pixel value is based not only on the corresponding original pixel value, but also the pixel values surrounding the original pixel. A blur, is more technically called a “moving average” filter due to the way it works. The blur is created by methodically looking at every pixel and assigning that (center) pixel the average of the pixels surrounding it. The more pixels one chooses to average (i.e. the larger the radius) the more blurred the image becomes. To try and make this idea more concrete, for those of us who wear glasses, if we take our glasses off, what we see is blurred. This is because light is not being focused properly, or we cannot make out details. Instead what we see is a basic average of the object in front of us.

Below is the pseudocode for the algorithm:

   for every pixel in the image do
   {
      R = G = B = 0;
      numpixels = 0;
      for every pixel in radius r surrounding the center pixel do
      {
         R += currentpixel.r;
         G += currentpixel.g;
         B += currentpixel.b;
         numpixels++;
      }
      filterpixel.r = R / numpixels;
      filterpixel.g = G / numpixels;
      filterpixel.b = B / numpixels;
   }

The above code uses a square area of pixels to calculate an average for a particular ‘center pixel’. In practice, for a large radius, it turns out that this tends to produce noticeable horizontal and vertical artifacts in the filtered image. By using a circular area of pixels, instead of a square, the artifacts were removed. However, the calculation to determine if a pixel is in a circle or not involves two multiplications and one square root operation. That calculation is noticeably more time consuming than just using a square for a large radius. Therefore, FilterExplorer allows the user to choose. In the blur dialog box, there is a check box called ‘Fast Blur’. If the box is checked, a square area of pixels is used instead of the circle.

This type of blur is good for removing noise in an image, however the obvious side effect is the loss of detail. The next filter, the median blur, tries to solve that problem.


Blur (radius 5)


Original image with noise added (not a filter)


Blur (radius 2) on original with noise


Return to the list of filters
 


© 2001 Jason Waltman