mexopencv  3.4.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",
46  "Unrecognized option %s", key.c_str());
47  }
48 
49  // Process
50  Mat src(rhs[0].toMat(rhs[0].isUint8() ? CV_8U :
51  (rhs[0].isUint16() ? CV_16U : CV_32F))),
52  mask(rhs[1].toMat(CV_8U)),
53  dst;
54  inpaint(src, mask, dst, inpaintRadius, flags);
55  plhs[0] = MxArray(dst);
56 }
#define CV_8U
STL namespace.
const ConstMap< string, int > InpaintType
Inpainting algorithm types for option processing.
Definition: inpaint.cpp:15
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
#define CV_32F
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: inpaint.cpp:27
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
#define CV_16U
INPAINT_TELEA
STL class.
Global constant definitions.
T c_str(T... args)
void inpaint(InputArray src, InputArray inpaintMask, OutputArray dst, double inpaintRadius, int flags)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
INPAINT_NS
cv::Mat toMat() const