9 #include "opencv2/ximgproc.hpp" 23 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
26 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
29 vector<MxArray> rhs(prhs, prhs+nrhs);
32 double maxValue = 255;
33 int type = cv::THRESH_BINARY;
35 for (
int i=2; i<nrhs; i+=2) {
36 string key(rhs[i].toString());
37 if (key ==
"MaxValue")
38 maxValue = rhs[i+1].toDouble();
39 else if (key ==
"Type")
41 else if (key ==
"BlockSize")
42 blockSize = rhs[i+1].toInt();
44 mexErrMsgIdAndTxt(
"mexopencv:error",
45 "Unrecognized option %s", key.c_str());
49 Mat src(rhs[0].toMat(CV_8U)), dst;
50 double delta = rhs[1].toDouble();
51 niBlackThreshold(src, dst, maxValue, type, blockSize, delta);
const ConstMap< std::string, int > ThreshType
Thresholding type map for option processing.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Global constant definitions.