15 (
"Mean", cv::ADAPTIVE_THRESH_MEAN_C)
16 (
"Gaussian", cv::ADAPTIVE_THRESH_GAUSSIAN_C);
26 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
29 nargchk(nrhs>=1 && (nrhs%2)==1 && nlhs<=1);
32 vector<MxArray> rhs(prhs, prhs+nrhs);
35 double maxValue = 255;
36 int adaptiveMethod = cv::ADAPTIVE_THRESH_MEAN_C;
37 int thresholdType = cv::THRESH_BINARY;
40 for (
int i=1; i<nrhs; i+=2) {
41 string key(rhs[i].toString());
42 if (key ==
"MaxValue")
43 maxValue = rhs[i+1].toDouble();
44 else if (key ==
"Method")
45 adaptiveMethod = AdaptiveMethod[rhs[i+1].toString()];
46 else if (key ==
"Type")
47 thresholdType =
ThreshType[rhs[i+1].toString()];
48 else if (key ==
"BlockSize")
49 blockSize = rhs[i+1].toInt();
51 C = rhs[i+1].toDouble();
53 mexErrMsgIdAndTxt(
"mexopencv:error",
54 "Unrecognized option %s", key.c_str());
58 Mat src(rhs[0].toMat(CV_8U)), dst;
59 adaptiveThreshold(src, dst, maxValue, adaptiveMethod, thresholdType,
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.
std::map wrapper with one-line initialization and lookup method.