cv::edgePreservingFilter() not working on grayscale images [closed]

asked 2016-12-08 22:28:12 -0600

updated 2018-01-22 20:01:42 -0600

Pretty much what the title says. It does however work on BGR images. I'm using a self-compiled build of OpenCV 3.1.0, if it matters.

If you run the MWE, the second call to cv::edgePreservingFilter() (on the grayscale image) appears to do nothing. Any ideas?

MWE:

#include <iostream>

#include <opencv2/core.hpp>
#include <opencv2/photo.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>

int main(int argc, char** argv)
{
    if (argc < 2) {
        std::cout << "Requires path to image" << std::endl;
        return 1;
    }

    cv::Mat image = cv::imread(argv[1]);

    cv::Mat filtered;
    cv::edgePreservingFilter(image, filtered);
    cv::imshow("RGB", filtered);
    cv::waitKey();

    cv::cvtColor(image, image, CV_BGR2GRAY);
    cv::edgePreservingFilter(image, filtered);
    cv::imshow("Grayscale", filtered);
    cv::waitKey();

    return 0;
}
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2016-12-09 00:36:51.521864

Comments

it clearly says so in the manual

berak gravatar imageberak ( 2016-12-09 00:18:33 -0600 )edit

Ack, thanks. That was idiotic of me...

JamesNZ gravatar imageJamesNZ ( 2016-12-09 00:31:50 -0600 )edit