Guided Filter: eps parameter not consistent with paper

asked 2017-10-24 12:54:47 -0600

julian gravatar image

updated 2020-11-06 04:15:33 -0600

OpenCV 3.3.0

It seems that the OpenCV implementation of the Guided Filter does not adhere to the parameter values proposed in the original paper as the results are not the same. I get good results only when I increase the epsilon by a large margin, much larger than anything proposed in the paper. I am wondering why that is and if there is a reason for this? If there is no mistake in my code I would suggest to adapt the code such that the API is more faithful to the paper.

Attached some examples and source code to reproduce:

Original image where the guided filter should be applied: image description

Image with applied guided filter using radius=8 and epsilon=0.4^2 image description

Image with applied guided filter using radius=8 and epsilon=2000 image description

#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/ximgproc.hpp>
using namespace cv::ximgproc;

int main() {
    cv::Mat image;
    image = cv::imread("../test/cat.bmp", 0);
    size_t r = 8;
    double eps = 0.4 * 0.4;

    cv::Mat dst;
    guidedFilter(image, image, dst, r, eps, -1);

    cv::namedWindow("Display Image", cv::WINDOW_AUTOSIZE );
    cv::imshow("Display Image", image);
    cv::waitKey(0);

    cv::namedWindow("Display Image", cv::WINDOW_AUTOSIZE );
    cv::imshow("Display Image (ocv gf)", dst);
    cv::waitKey(0);
}
edit retag flag offensive close merge delete