mexopencv  3.4.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
#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...
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
#define CV_16U
STL class.
void l0Smooth(InputArray src, OutputArray dst, double lambda=0.02, double kappa=2.0)
Global constant definitions.
T c_str(T... args)
cv::Mat toMat() const