9 #include "opencv2/photo.hpp" 20 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
23 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
26 vector<MxArray> rhs(prhs, prhs+nrhs);
31 int templateWindowSize = 7;
32 int searchWindowSize = 21;
34 for (
int i=3; i<nrhs; i+=2) {
35 string key(rhs[i].toString());
37 h = rhs[i+1].toFloat();
38 else if (key ==
"HColor")
39 hColor = rhs[i+1].toFloat();
40 else if (key ==
"TemplateWindowSize")
41 templateWindowSize = rhs[i+1].toInt();
42 else if (key ==
"SearchWindowSize")
43 searchWindowSize = rhs[i+1].toInt();
44 else if (key ==
"FlipChannels")
45 flip = rhs[i+1].toBool();
47 mexErrMsgIdAndTxt(
"mexopencv:error",
48 "Unrecognized option %s", key.c_str());
54 vector<MxArray> arr(rhs[0].toVector<MxArray>());
55 srcImgs.reserve(arr.size());
56 for (vector<MxArray>::const_iterator it = arr.begin(); it != arr.end(); ++it)
57 srcImgs.push_back(it->toMat(CV_8U));
59 for (vector<Mat>::iterator it = srcImgs.begin(); it != srcImgs.end(); ++it) {
60 if (flip && (it->channels() == 3 || it->channels() == 4)) {
62 cvtColor(*it, *it, (it->channels()==3 ?
63 cv::COLOR_BGR2RGB : cv::COLOR_BGRA2RGBA));
66 int imgToDenoiseIndex = rhs[1].toInt();
67 int temporalWindowSize = rhs[2].toInt();
69 fastNlMeansDenoisingColoredMulti(srcImgs, dst, imgToDenoiseIndex,
70 temporalWindowSize, h, hColor, templateWindowSize, searchWindowSize);
71 if (flip && (dst.channels() == 3 || dst.channels() == 4)) {
73 cvtColor(dst, dst, (dst.channels()==3 ?
74 cv::COLOR_BGR2RGB : cv::COLOR_BGRA2RGBA));
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.