mexopencv  0.1
mex interface for opencv library
applyColorMap.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
12 namespace {
14 const ConstMap<string,int> ColormapTypesMap = ConstMap<string,int>
15  ("Autumn", cv::COLORMAP_AUTUMN)
16  ("Bone", cv::COLORMAP_BONE)
17  ("Jet", cv::COLORMAP_JET)
18  ("Winter", cv::COLORMAP_WINTER)
19  ("Rainbow", cv::COLORMAP_RAINBOW)
20  ("Ocean", cv::COLORMAP_OCEAN)
21  ("Summer", cv::COLORMAP_SUMMER)
22  ("Spring", cv::COLORMAP_SPRING)
23  ("Cool", cv::COLORMAP_COOL)
24  ("Hsv", cv::COLORMAP_HSV)
25  ("Pink", cv::COLORMAP_PINK)
26  ("Hot", cv::COLORMAP_HOT)
27  ("Parula", cv::COLORMAP_PARULA);
28 }
29 
37 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
38 {
39  // Check the number of arguments
40  nargchk(nrhs==2 && nlhs<=1);
41 
42  // Argument vector
43  vector<MxArray> rhs(prhs, prhs+nrhs);
44 
45  // Process
46  Mat src(rhs[0].toMat(CV_8U)), dst;
47  int colormap = ColormapTypesMap[rhs[1].toString()];
48  applyColorMap(src, dst, colormap);
49  cvtColor(dst, dst, cv::COLOR_BGR2RGB); // flip 3rd dim
50  plhs[0] = MxArray(dst);
51 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Definition: mexopencv.hpp:166
Global constant definitions.
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927