opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.34k stars 5.75k forks source link

Guided filter cuts right part of an image #1288

Open velikodniy opened 7 years ago

velikodniy commented 7 years ago
System information (version)
Detailed description

I filter images with 3:4 aspect ratio. I've found that if image height is greater than 625 then the guided filter cuts one third of the filtered image like on the figures below.

I believe it's because of too small value of eps (1e-6).

Images (img and img_mask respectively):

Result (dst_mask):

I've also found that if I use landscape orientation (for example 1280×960 instead 960×1280) then the filter works as usual.

Steps to reproduce

I used this code:

#include <opencv2/opencv.hpp>
#include <opencv2/ximgproc/edge_filter.hpp>

int main(int argc, char** argv)
{
    cv::Mat img, img_mask, dst_mask;

    img = cv::imread(argv[1], cv::IMREAD_COLOR);
    img_mask = cv::imread(argv[2], cv::IMREAD_GRAYSCALE);

    cv::ximgproc::guidedFilter(img, img_mask, dst_mask, 60, 1e-6);

    cv::imwrite(argv[3], dst_mask);
    return 0;
}
berak commented 7 years ago

cannot reproduce it with current 3.3-rc (using your code & images)

velikodniy commented 7 years ago

Maybe https://github.com/opencv/opencv_contrib/commit/7cc7414a51cfcd189ce4311e84f992a42b7d6028 fixed it. Unfortunately I cannot check versions newer than 3.1.0 at the moment.

n1n3b1t commented 7 years ago

It does reproduce on Android, but only on 32bit architectures(armeabi-v7a), works fine on arm64-v8a