9 #include "opencv2/photo.hpp" 16 (
"Recursive", cv::RECURS_FILTER)
17 (
"NormConv", cv::NORMCONV_FILTER);
27 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
30 nargchk(nrhs>=1 && (nrhs%2)==1 && nlhs<=1);
33 vector<MxArray> rhs(prhs, prhs+nrhs);
36 int flags = cv::RECURS_FILTER;
38 float sigma_r = 0.04f;
40 for (
int i=1; i<nrhs; i+=2) {
41 string key(rhs[i].toString());
43 flags = EdgePreseveFilterMap[rhs[i+1].toString()];
44 else if (key ==
"SigmaS")
45 sigma_s = rhs[i+1].toFloat();
46 else if (key ==
"SigmaR")
47 sigma_r = rhs[i+1].toFloat();
48 else if (key ==
"FlipChannels")
49 flip = rhs[i+1].toBool();
51 mexErrMsgIdAndTxt(
"mexopencv:error",
52 "Unrecognized option %s", key.c_str());
56 Mat src(rhs[0].toMat(CV_8U)), dst;
57 if (flip && src.channels() == 3) {
59 cvtColor(src, src, cv::COLOR_RGB2BGR);
61 edgePreservingFilter(src, dst, flags, sigma_s, sigma_r);
62 if (flip && dst.channels() == 3) {
64 cvtColor(dst, dst, cv::COLOR_BGR2RGB);
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.