42 int id = rhs[0].toInt();
43 string method(rhs[1].toString());
46 if (method ==
"new") {
47 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
51 for (
int i=3; i<nrhs; i+=2) {
52 string key(rhs[i].toString());
53 if (key ==
"Algorithm")
55 else if (key ==
"RegionSize")
56 region_size = rhs[i+1].toInt();
57 else if (key ==
"Ruler")
58 ruler = rhs[i+1].toFloat();
61 "Unrecognized option %s", key.
c_str());
65 image, algorithm, region_size, ruler);
75 if (method ==
"delete") {
80 else if (method ==
"clear") {
84 else if (method ==
"load") {
85 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
87 bool loadFromString =
false;
88 for (
int i=3; i<nrhs; i+=2) {
89 string key(rhs[i].toString());
91 objname = rhs[i+1].toString();
92 else if (key ==
"FromString")
93 loadFromString = rhs[i+1].toBool();
96 "Unrecognized option %s", key.
c_str());
105 FileStorage fs(rhs[2].toString(), FileStorage::READ +
106 (loadFromString ? FileStorage::MEMORY : 0));
115 else if (method ==
"save") {
117 obj->
save(rhs[2].toString());
119 else if (method ==
"empty") {
123 else if (method ==
"getDefaultName") {
127 else if (method ==
"iterate") {
128 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs==0);
129 int num_iterations = 10;
130 for (
int i=2; i<nrhs; i+=2) {
131 string key(rhs[i].toString());
132 if (key ==
"NumIterations")
133 num_iterations = rhs[i+1].toInt();
136 "Unrecognized option %s", key.
c_str());
140 else if (method ==
"getNumberOfSuperpixels") {
144 else if (method ==
"getLabels") {
150 else if (method ==
"getLabelContourMask") {
151 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
152 bool thick_line =
true;
153 for (
int i=2; i<nrhs; i+=2) {
154 string key(rhs[i].toString());
155 if (key ==
"ThickLine")
156 thick_line = rhs[i+1].toBool();
159 "Unrecognized option %s", key.
c_str());
165 else if (method ==
"enforceLabelConnectivity") {
166 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs==0);
167 int min_element_size = 25;
168 for (
int i=2; i<nrhs; i+=2) {
169 string key(rhs[i].toString());
170 if (key ==
"MinElementSize")
171 min_element_size = rhs[i+1].toInt();
174 "Unrecognized option %s", key.
c_str());
180 "Unrecognized operation %s", method.
c_str());
const ConstMap< string, int > SLICAlgorithmMap
Option values for SLIC algorithms.
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void iterate(int num_iterations=10)=0
virtual void read(const FileNode &fn)
map< int, Ptr< SuperpixelSLIC > > obj_
Object container.
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
virtual void getLabels(OutputArray labels_out) const=0
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
FileNode getFirstTopLevelNode() const
virtual int getNumberOfSuperpixels() const=0
virtual String getDefaultName() const
Global constant definitions.
virtual void getLabelContourMask(OutputArray image, bool thick_line=true) const=0
virtual void save(const String &filename) const
virtual bool empty() const
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Ptr< SuperpixelSLIC > createSuperpixelSLIC(InputArray image, int algorithm=SLICO, int region_size=10, float ruler=10.0f)
std::map wrapper with one-line initialization and lookup method.
int last_id
Last object id to allocate.
virtual void enforceLabelConnectivity(int min_element_size=25)=0