Ask Your Question
0

Is there any problem in using the same src and dst image in filtering functions?

asked 2014-03-27 05:03:07 -0600

mb gravatar image

Filtering operations can't be done in the same image since the convolution needs points at already processed positions right? And if I update the same image I get that i'm convolutiong using filtered values instead of original ones. The question is: are the opencv functions like GaussianBlur(.), blur(.), medianBlur(.), bilateralBlur(.) and so on safe to this issue? (doeas opencv create a temporary second matrix internally?) In other words Can I set the "src" and "dst" parameters to the same Mat reference?

ps. I'm writing in C++

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-03-27 10:41:20 -0600

ajplockyer gravatar image

Yes, src and dst can be the same matrix. The following code works fine:

int main(int argc, char argv[]) {
    cv::Mat test = cv::imread("test.jpg");
    cv::GaussianBlur(test, test, cv::Size(11, 11), 5.0);
    cv::imshow("test", test);
    cv::waitKey(0);
    return 0;
}
edit flag offensive delete link more

Comments

thanks for replying. Yes it looks fine for blur and GaussianBlur, but for bilateralBlur it gives me this:

OpenCV Error: Assertion failed ((src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.type() == dst.type() && src.size() == dst.size() && src.data != dst.data) in bilateralFilter_8u, file /build/opencv/src/opencv-2.4.7/modules/imgproc/src/smooth.cpp, line 1925 terminate called after throwing an instance of 'cv::Exception' what(): /build/opencv/src/opencv-2.4.7/modules/imgproc/src/smooth.cpp:1925: error: (-215) (src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.type() == dst.type() && src.size() == dst.size() && src.data != dst.data in function bilateralFilter_8u

mb gravatar imagemb ( 2014-03-27 12:50:36 -0600 )edit

Could you link to documentation saying that src and dst can be the same? It would be helpful to know that this is part of the method's contract, and not just an implementation detail dependent on one specific release.

dinosaur gravatar imagedinosaur ( 2016-07-06 17:56:02 -0600 )edit

Question Tools

Stats

Asked: 2014-03-27 05:03:07 -0600

Seen: 7,680 times

Last updated: Mar 27 '14