9 #include "opencv2/photo.hpp" 20 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
23 nargchk(nrhs>=1 && (nrhs%2)==1 && nlhs<=2);
26 vector<MxArray> rhs(prhs, prhs+nrhs);
30 for (
int i=1; i<nrhs; i+=2) {
31 string key(rhs[i].toString());
32 if (key ==
"FlipChannels")
33 flip = rhs[i+1].toBool();
35 mexErrMsgIdAndTxt(
"mexopencv:error",
36 "Unrecognized option %s", key.c_str());
40 Mat color(rhs[0].toMat(CV_8U)), grayscale, color_boost;
41 if (flip && color.channels()==3) {
43 cvtColor(color, color, cv::COLOR_RGB2BGR);
45 decolor(color, grayscale, color_boost);
46 if (flip && color_boost.channels()==3) {
48 cvtColor(color_boost, color_boost, 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.