15 (
"Otsu", cv::THRESH_OTSU)
16 (
"Triangle", cv::THRESH_TRIANGLE);
26 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
29 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=2);
32 vector<MxArray> rhs(prhs, prhs+nrhs);
36 int type = cv::THRESH_BINARY;
37 for (
int i=2; i<nrhs; i+=2) {
38 string key(rhs[i].toString());
39 if (key ==
"MaxValue")
40 maxval = rhs[i+1].toDouble();
41 else if (key ==
"Type")
44 mexErrMsgIdAndTxt(
"mexopencv:error",
45 "Unrecognized option %s", key.c_str());
51 type |= AutoThresholdTypesMap[rhs[1].toString()];
53 thresh = rhs[1].toDouble();
56 Mat src(rhs[0].toMat(rhs[0].isUint8() ? CV_8U :
57 (rhs[0].isInt16() ? CV_16S : CV_32F))), dst;
58 thresh = threshold(src, dst, thresh, maxval, type);
const ConstMap< std::string, int > ThreshType
Thresholding type map for option processing.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Global constant definitions.
std::map wrapper with one-line initialization and lookup method.