Reputation: 55
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?
Upvotes: 1
Views: 6669
Reputation: 13945
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!
Upvotes: 1