15 (
"3", cv::DIST_MASK_3)
16 (
"5", cv::DIST_MASK_5)
17 (
"Precise", cv::DIST_MASK_PRECISE);
21 (
"CComp", cv::DIST_LABEL_CCOMP)
22 (
"Pixel", cv::DIST_LABEL_PIXEL);
32 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
35 nargchk(nrhs>=1 && (nrhs%2)==1 && nlhs<=2);
38 vector<MxArray> rhs(prhs, prhs+nrhs);
39 bool with_labels = (nlhs > 1);
42 int distanceType = cv::DIST_L2;
43 int maskSize = cv::DIST_MASK_3;
44 int labelType = cv::DIST_LABEL_CCOMP;
46 for (
int i=1; i<nrhs; i+=2) {
47 string key(rhs[i].toString());
48 if (key==
"DistanceType")
49 distanceType =
DistType[rhs[i+1].toString()];
50 else if (key==
"MaskSize")
51 maskSize = (rhs[i+1].isChar()) ?
52 DistMask[rhs[i+1].toString()] : rhs[i+1].toInt();
53 else if (with_labels && key==
"LabelType")
54 labelType = DistLabelTypes[rhs[i+1].toString()];
55 else if (!with_labels && key==
"DstType")
58 mexErrMsgIdAndTxt(
"mexopencv:error",
"Unrecognized option");
62 Mat src(rhs[0].toMat(CV_8U)), dst;
65 distanceTransform(src, dst, labels, distanceType, maskSize, labelType);
69 distanceTransform(src, dst, distanceType, maskSize, dstType);
const ConstMap< std::string, int > ClassNameMap
Translates class name used in MATLAB to equivalent OpenCV depth.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
const ConstMap< std::string, int > DistType
Distance types for Distance Transform and M-estimators.
Global constant definitions.
std::map wrapper with one-line initialization and lookup method.