mexopencv  3.4.1
MEX interface for OpenCV library
rollingGuidanceFilter.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 #include "opencv2/ximgproc.hpp"
10 using namespace std;
11 using namespace cv;
12 using namespace cv::ximgproc;
13 
21 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
22 {
23  // Check the number of arguments
24  nargchk(nrhs>=1 && (nrhs%2)==1 && nlhs<=1);
25 
26  // Argument vector
27  vector<MxArray> rhs(prhs, prhs+nrhs);
28 
29  // Option processing
30  int d = -1;
31  double sigmaColor = 25.0;
32  double sigmaSpace = 3.0;
33  int numOfIter = 4;
34  int borderType = cv::BORDER_DEFAULT;
35  for (int i=1; i<nrhs; i+=2) {
36  string key(rhs[i].toString());
37  if (key == "Diameter")
38  d = rhs[i+1].toInt();
39  else if (key == "SigmaColor")
40  sigmaColor = rhs[i+1].toDouble();
41  else if (key == "SigmaSpace")
42  sigmaSpace = rhs[i+1].toDouble();
43  else if (key == "NumIter")
44  numOfIter = rhs[i+1].toInt();
45  else if (key == "BorderType")
46  borderType = BorderType[rhs[i+1].toString()];
47  else
48  mexErrMsgIdAndTxt("mexopencv:error",
49  "Unrecognized option %s", key.c_str());
50  }
51 
52  // Process
53  Mat src(rhs[0].toMat(rhs[0].isUint8() ? CV_8U : CV_32F)),
54  dst;
55  rollingGuidanceFilter(src, dst,
56  d, sigmaColor, sigmaSpace, numOfIter, borderType);
57  plhs[0] = MxArray(dst);
58 }
#define CV_8U
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
#define CV_32F
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
const ConstMap< std::string, int > BorderType
Border type map for option processing.
Definition: mexopencv.hpp:66
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/output arguments number check.
Definition: mexopencv.hpp:181
STL class.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Global constant definitions.
T c_str(T... args)
void rollingGuidanceFilter(InputArray src, OutputArray dst, int d=-1, double sigmaColor=25, double sigmaSpace=3, int numOfIter=4, int borderType=BORDER_DEFAULT)
BORDER_DEFAULT
cv::Mat toMat() const