15 (
"Erode", cv::MORPH_ERODE)
16 (
"Dilate", cv::MORPH_DILATE)
17 (
"Open", cv::MORPH_OPEN)
18 (
"Close", cv::MORPH_CLOSE)
19 (
"Gradient", cv::MORPH_GRADIENT)
20 (
"Tophat", cv::MORPH_TOPHAT)
21 (
"Blackhat", cv::MORPH_BLACKHAT)
22 (
"HitMiss", cv::MORPH_HITMISS);
32 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
35 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
38 vector<MxArray> rhs(prhs, prhs+nrhs);
44 int borderType = cv::BORDER_CONSTANT;
45 Scalar borderValue = morphologyDefaultBorderValue();
46 for (
int i=2; i<nrhs; i+=2) {
47 string key(rhs[i].toString());
49 kernel = rhs[i+1].toMat(CV_8U);
50 else if (key==
"Anchor")
51 anchor = rhs[i+1].toPoint();
52 else if (key==
"Iterations")
53 iterations = rhs[i+1].toInt();
54 else if (key==
"BorderType")
56 else if (key==
"BorderValue")
57 borderValue = rhs[i+1].toScalar();
59 mexErrMsgIdAndTxt(
"mexopencv:error",
"Unrecognized option");
63 Mat src(rhs[0].toMat()), dst;
64 int op = MorphType[rhs[1].toString()];
65 morphologyEx(src, dst, op, kernel, anchor, iterations,
66 borderType, borderValue);
const ConstMap< std::string, int > BorderType
Border 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.