Geometric mean filter

The geometric mean filter is an image filtering process meant to smooth and reduce noise of an image.[1] It is based on the mathematic geometric mean. The output image G(x,y) of a geometric mean is given by

Where S(x,y) is the original image, and the filter mask is m by n pixels.

Each pixel of the output image at point (x,y) is given by the product of the pixels within the geometric mean mask raised to the power of 1/mn. For example, using a mask size of 3 by 3, pixel (x,y) in the output image will be the product of S(x,y) and all 8 of its surrounding pixels raised to the 1/9th power.

Using the following original image with pixel (x,y) at the center:

Gives the result of: (5*16*22*6*3*18*12*3*15)^(1/9) = 8.77.

Application

The geometric mean filter is most widely used to filter out Gaussian noise. In general it will help smooth the image with less data loss than an arithmetic mean filter.[1]

Code example

The following code shows the application of a geometric mean filter to an image using MATLAB.

 1 %Applies geometric mean filter to image input_noise that has added gaussian noise
 2 
 3 [m, n] = size(input_noise);                  
 4 output = zeros(m, n);                       %output image set with placeholder values of all zeros
 5 val = 1;                                    %variable to hold new pixel value
 6 
 7 for i = 2:m-2                               %loop through each pixel in original image
 8     for j = 2:n-2                           %compute geometric mean of 3x3 window around pixel
 9         p = input_noise(i-1, j-1);
10         q = input_noise(i-1, j);
11         r = input_noise(i-1, j+1);
12         s = input_noise(i, j-1);
13         t = input_noise(i, j);
14         u = input_noise(i, j+1);
15         v = input_noise(i+1, j-1);
16         w = input_noise(i+1, j);
17         x = input_noise(i+1, j+1);
18         
19         val = (p*q*r*s*t*u*v*w*x) ^ (1/9);
20         output(i, j) = val;                 %set output pixel to computed geometric mean
21         val = 1;                            %reset val for next pixel
22     end
23 end
Input image with added gaussian noise
Output image after filter

References

  1. Gonzalez, Rafael (2002). Digital Image Processing 3nd Edition. Prentice Hall. pp. 232–233. ISBN 0201180758.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.