mexopencv  0.1
mex interface for opencv library
l0Smooth.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  double lambda = 0.02;
31  double kappa = 2.0;
32  for (int i=1; i<nrhs; i+=2) {
33  string key(rhs[i].toString());
34  if (key == "Lambda")
35  lambda = rhs[i+1].toDouble();
36  else if (key == "Kappa")
37  kappa = rhs[i+1].toDouble();
38  else
39  mexErrMsgIdAndTxt("mexopencv:error",
40  "Unrecognized option %s", key.c_str());
41  }
42 
43  // Process
44  Mat src(rhs[0].toMat(rhs[0].isUint8() ? CV_8U :
45  (rhs[0].isUint16() ? CV_16U : CV_32F))),
46  dst;
47  l0Smooth(src, dst, lambda, kappa);
48  plhs[0] = MxArray(dst);
49 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: l0Smooth.cpp:21
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Definition: mexopencv.hpp:166
Global constant definitions.