Reputation: 4183
I am using OpenCV 2.3.1.
I have a cv::Mat image and I would like to apply a smoothing filter. Unfortunately, all I code find was
void cvSmooth(const CvArr* src, CvArr* dst, int smoothtype=CV_GAUSSIAN, int size1=3, int size2=0, double sigma1=0, double sigma2=0 );
which uses CvArr instead of cv::Mat. I could not find an explanation about how to convert between cv::Mat and CvArr.
Any assistance with this would be greatly appreciated.
Upvotes: 2
Views: 4779
Reputation: 26730
As stated in the docs:
Note: The function is now obsolete. Use GaussianBlur(), blur(), medianBlur() or bilateralFilter().
For all these functions, C++ interfaces exist, e.g.:
void GaussianBlur(InputArray src, OutputArray dst, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT )
Upvotes: 4
Reputation: 909
First you load you image as you want, for me I used :
image = cvLoadImage("6mtEy.jpg");
As far as I know if you want to use this function your gona need to convert your Mat into a cvArr (IplImage in my code) :
IplImage tmp = image;
Then you create your destination image with the same size etc as your first picture :
IplImage *dst;
dst = cvCreateImage(cvSize(tmp.width, tmp.height), tmp.depth, tmp.nChannels);
Then you use your function :
cvSmooth(&tmp, dst, CV_GAUSSIAN, 1);
And finally you put the result back in a mat :
image = dst;
After don't forget to destroy the IplImages you created.
Upvotes: 1