Geometric mean filter


The geometric mean filter is an image filtering process meant to smooth and reduce noise of an image. It is based on the mathematic geometric mean. The output image G of a geometric mean is given by
Where S is the original image, and the filter mask is m by n pixels.
Each pixel of the output image at point 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 in the output image will be the product of S and all 8 of its surrounding pixels raised to the 1/9th power.
Using the following original image with pixel at the center:
Gives the result of: ^ = 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.

Code example

The following code shows the application of a geometric mean filter to an image using MATLAB.
%Applies geometric mean filter to image input_noise that has added gaussian noise
= size;
output = zeros; %output image set with placeholder values of all zeros
val = 1; %variable to hold new pixel value
for i = 2:m-2 %loop through each pixel in original image
for j = 2:n-2 %compute geometric mean of 3x3 window around pixel
p = input_noise;
q = input_noise;
r = input_noise;
s = input_noise;
t = input_noise;
u = input_noise;
v = input_noise;
w = input_noise;
x = input_noise;

val = ^ ;
output = val; %set output pixel to computed geometric mean
val = 1; %reset val for next pixel
end
end