1

I am new to MATLAB. I don't know how to use geometric mean filter for filtering noisy image. For arithmetic mean filter I use this:

H = fspecial('average',5);
a = imfilter(a, H);

Is there any similar way for geometric mean filter?

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
yld
  • 35
  • 2
  • 9

1 Answers1

1

Yes there is. I suggest reading both the Wikipedia page about geometric mean as well as this blog by Steve Eddins who works at The Mathworks.

To borrow Steve's explanation (and whole code/example actually):

The local geometric mean filter multiplies together all the pixel values in the neighborhood and then takes the N-th root, where N is the number of pixels in the neighborhood.

So in terms of Matlab code, with h being the kernel filled with ones having size of the neighborhood you use to compute the average and I being your image:

geo_mean = imfilter(log(I), h, 'replicate');
geo_mean = exp(geo_mean);
geo_mean = geo_mean .^ (1/numel(h));

Hope that helps!

akurmustafa
  • 122
  • 10
Benoit_11
  • 13,905
  • 2
  • 24
  • 35