Geometric mean filter in MATLAB

Viewed 53
I = imread("example.tif");

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

It gives the following error. Also, What do I need to write instead of 'h' parameter?

Check for incorrect argument data type or missing argument in call to function 'log'.
1 Answers

Follow the following example with comments for illustration.

I = imread('example.tif'); 

% Convert the image to double.
I = rgb2gray(im2double(I));

% Create the function you want to apply to the image — a geometric mean filter.
fun = @(x) geomean(x(:));

% Apply the filter to the image.
G = nlfilter(I,[5 5],fun); 

% Display the original image and the filtered image, side-by-side.
montage({I,G})
title('Original Image (Left) and Geometric-Mean Filtered Image (Right)')

enter image description here

Related