Reputation: 613
Filtering operations involve convolutions and the filtered value at position (x,y)
will also depend on the intensities of pixels (x-a,y-b)
with a,b >0
.
So using directly as destination the same image will lead to unexpected behaviors because during calculation I'm taking some already-filtered data instead of original ones.
Does opencv
manage this issue internally in functions like cv::GaussianBlur(.)
, cv::blur
, etc? Is it safe to give a reference to the same Mat
to both src
and dst
parameters?
thanks
Upvotes: 14
Views: 3855
Reputation: 5679
Yes, there would not be any problem if you do so. I have done such thing several time. openCV will automatically take care of it.
I tested the following code and it works perfect:
int main(int argc, char* argv[])
{
Mat src;
src = imread("myImage.jpeg", 1);
imshow("src", src); //Original src
cv::blur( src, src, Size(25,25) , Point(-1,-1), BORDER_DEFAULT );
imshow("dst", src); //src after blurring
waitKey(0);
}
Upvotes: 9