mexopencv  3.4.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.
#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.
Global constant definitions.
T c_str(T... args)
BORDER_DEFAULT
cv::Mat toMat() const
void jointBilateralFilter(InputArray joint, InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT)