function [processed_img] = apply_wallis_operator(in_img, local_mean_img, desired_mean, local_contrast_img, desired_contrast, A_max, p)
    processed_img = zeros(size(in_img));
    for n1 = 1:size(processed_img,1)
        for n2 = 1:size(processed_img,2)
            processed_img(n1,n2) = (in_img(n1,n2) - local_mean_img(n1,n2))*((A_max*desired_contrast)/(A_max*local_contrast_img(n1,n2)+desired_contrast)) + (p*desired_mean + (1-p)*local_mean_img(n1,n2));
        end
    end
end