mexopencv  3.4.1
MEX interface for OpenCV library
GradientPaillou.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>=2 && (nrhs%2)==0 && nlhs<=1);
25 
26  // Argument vector
27  vector<MxArray> rhs(prhs, prhs+nrhs);
28 
29  // Option processing
30  double alpha = 1.0;
31  double omega = 0.1;
32  for (int i=2; i<nrhs; i+=2) {
33  string key(rhs[i].toString());
34  if (key == "Alpha")
35  alpha = rhs[i+1].toDouble();
36  else if (key == "Omega")
37  omega = rhs[i+1].toDouble();
38  else
39  mexErrMsgIdAndTxt("mexopencv:error",
40  "Unrecognized option %s", key.c_str());
41  }
42 
43  // Process
44  Mat op(rhs[0].toMat()), // 8u, 8s, 16u, 16s
45  dst;
46  string dir(rhs[1].toString());
47  if (dir == "X")
48  GradientPaillouX(op, dst, alpha, omega);
49  else if (dir == "Y")
50  GradientPaillouY(op, dst, alpha, omega);
51  else
52  mexErrMsgIdAndTxt("mexopencv:error", "Invalid arguments");
53  plhs[0] = MxArray(dst);
54 }
STL namespace.
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
void GradientPaillouX(InputArray op, OutputArray _dst, double alpha, double omega)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
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
STL class.
Global constant definitions.
T c_str(T... args)
void GradientPaillouY(InputArray op, OutputArray _dst, double alpha, double omega)
cv::Mat toMat() const