mexopencv  0.1
mex interface for opencv library
inpaint.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 #include "opencv2/photo.hpp"
10 using namespace std;
11 using namespace cv;
12 
13 namespace {
16  ("NS", cv::INPAINT_NS)
17  ("Telea", cv::INPAINT_TELEA);
18 }
19 
27 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
28 {
29  // Check the number of arguments
30  nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
31 
32  // Argument vector
33  vector<MxArray> rhs(prhs, prhs+nrhs);
34 
35  // Option processing
36  double inpaintRadius = 3.0;
37  int flags = cv::INPAINT_NS;
38  for (int i=2; i<nrhs; i+=2) {
39  string key(rhs[i].toString());
40  if (key=="Radius")
41  inpaintRadius = rhs[i+1].toDouble();
42  else if (key=="Method")
43  flags = InpaintType[rhs[i+1].toString()];
44  else
45  mexErrMsgIdAndTxt("mexopencv:error","Unrecognized option");
46  }
47 
48  // Process
49  Mat src(rhs[0].toMat(CV_8U)),
50  mask(rhs[1].toMat(CV_8U)),
51  dst;
52  inpaint(src, mask, dst, inpaintRadius, flags);
53  plhs[0] = MxArray(dst);
54 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: inpaint.cpp:27
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.
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927