mexopencv  0.1
mex interface for opencv library
pyrMeanShiftFiltering.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
19 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
20 {
21  // Check the number of arguments
22  nargchk(nrhs>=1 && (nrhs%2)==1 && nlhs<=1);
23 
24  // Argument vector
25  vector<MxArray> rhs(prhs, prhs+nrhs);
26 
27  // Option processing
28  double sp = 5;
29  double sr = 10;
30  int maxLevel = 1;
31  TermCriteria termcrit(TermCriteria::MAX_ITER+TermCriteria::EPS, 5, 1);
32  for (int i=1; i<nrhs; i+=2) {
33  string key(rhs[i].toString());
34  if (key=="SP")
35  sp = rhs[i+1].toDouble();
36  else if (key=="SR")
37  sr = rhs[i+1].toDouble();
38  else if (key=="MaxLevel")
39  maxLevel = rhs[i+1].toInt();
40  else if (key=="Criteria")
41  termcrit = rhs[i+1].toTermCriteria();
42  else
43  mexErrMsgIdAndTxt("mexopencv:error","Unrecognized option");
44  }
45 
46  // Process
47  Mat src(rhs[0].toMat(CV_8U)), dst;
48  pyrMeanShiftFiltering(src, dst, sp, sr, maxLevel, termcrit);
49  plhs[0] = MxArray(dst);
50 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
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.