mexopencv  0.1
mex interface for opencv library
jointBilateralFilter.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  int d = -1;
31  double sigmaColor = 25.0;
32  double sigmaSpace = 10.0;
33  int borderType = cv::BORDER_DEFAULT;
34  for (int i=2; i<nrhs; i+=2) {
35  string key(rhs[i].toString());
36  if (key == "Diameter")
37  d = rhs[i+1].toInt();
38  else if (key == "SigmaColor")
39  sigmaColor = rhs[i+1].toDouble();
40  else if (key == "SigmaSpace")
41  sigmaSpace = rhs[i+1].toDouble();
42  else if (key == "BorderType")
43  borderType = BorderType[rhs[i+1].toString()];
44  else
45  mexErrMsgIdAndTxt("mexopencv:error",
46  "Unrecognized option %s", key.c_str());
47  }
48 
49  // Process
50  Mat src(rhs[0].toMat(rhs[0].isUint8() ? CV_8U : CV_32F)),
51  joint(rhs[1].toMat(rhs[1].isUint8() ? CV_8U : CV_32F)),
52  dst;
53  jointBilateralFilter(joint, src, dst,
54  d, sigmaColor, sigmaSpace, borderType);
55  plhs[0] = MxArray(dst);
56 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
const ConstMap< std::string, int > BorderType
Border type map for option processing.
Definition: mexopencv.hpp:52
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.