19 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
22 nargchk(nrhs>=1 && (nrhs%2)!=0 && nlhs<=1);
25 vector<MxArray> rhs(prhs, prhs+nrhs);
28 double alpha = 1.0, beta = 0.0;
29 int norm_type = cv::NORM_L2;
32 for (
int i=1; i<nrhs; i+=2) {
33 string key(rhs[i].toString());
35 alpha = rhs[i+1].toDouble();
36 else if (key ==
"Beta")
37 beta = rhs[i+1].toDouble();
38 else if (key ==
"NormType")
39 norm_type = (rhs[i+1].isChar()) ?
40 NormType[rhs[i+1].toString()] : rhs[i+1].toInt();
41 else if (key ==
"DType")
42 dtype = (rhs[i+1].isChar()) ?
44 else if (key ==
"Mask")
45 mask = rhs[i+1].toMat(CV_8U);
46 else if (key ==
"Dest") {
47 dst = rhs[i+1].toMat();
51 mexErrMsgIdAndTxt(
"mexopencv:error",
52 "Unrecognized option %s", key.c_str());
56 Mat src(rhs[0].toMat());
57 if (!mask.empty() && dst.empty()) {
59 int dst_depth = (dtype < 0) ? src.depth() : dtype;
60 dst.create(src.size(), CV_MAKETYPE(dst_depth, src.channels()));
61 src.convertTo(dst, dst_depth);
64 normalize(src, dst, alpha, beta, norm_type, dtype, mask);
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.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Global constant definitions.
const ConstMap< std::string, int > NormType
Norm type map for option processing.