36 int id = rhs[0].toInt();
37 string method(rhs[1].toString());
40 if (method ==
"new") {
41 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
44 for (
int i=3; i<nrhs; i+=2) {
45 string key(rhs[i].toString());
46 if (key ==
"RegionSize")
47 region_size = rhs[i+1].toInt();
48 else if (key ==
"Ratio")
49 ratio = rhs[i+1].toFloat();
52 "Unrecognized option %s", key.
c_str());
65 if (method ==
"delete") {
70 else if (method ==
"clear") {
74 else if (method ==
"load") {
75 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
77 bool loadFromString =
false;
78 for (
int i=3; i<nrhs; i+=2) {
79 string key(rhs[i].toString());
81 objname = rhs[i+1].toString();
82 else if (key ==
"FromString")
83 loadFromString = rhs[i+1].toBool();
86 "Unrecognized option %s", key.
c_str());
95 FileStorage fs(rhs[2].toString(), FileStorage::READ +
96 (loadFromString ? FileStorage::MEMORY : 0));
105 else if (method ==
"save") {
107 obj->
save(rhs[2].toString());
109 else if (method ==
"empty") {
113 else if (method ==
"getDefaultName") {
117 else if (method ==
"iterate") {
118 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs==0);
119 int num_iterations = 10;
120 for (
int i=2; i<nrhs; i+=2) {
121 string key(rhs[i].toString());
122 if (key ==
"NumIterations")
123 num_iterations = rhs[i+1].toInt();
126 "Unrecognized option %s", key.
c_str());
130 else if (method ==
"getNumberOfSuperpixels") {
134 else if (method ==
"getLabels") {
140 else if (method ==
"getLabelContourMask") {
141 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
142 bool thick_line =
true;
143 for (
int i=2; i<nrhs; i+=2) {
144 string key(rhs[i].toString());
145 if (key ==
"ThickLine")
146 thick_line = rhs[i+1].toBool();
149 "Unrecognized option %s", key.
c_str());
155 else if (method ==
"enforceLabelConnectivity") {
156 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs==0);
157 int min_element_size = 20;
158 for (
int i=2; i<nrhs; i+=2) {
159 string key(rhs[i].toString());
160 if (key ==
"MinElementSize")
161 min_element_size = rhs[i+1].toInt();
164 "Unrecognized option %s", key.
c_str());
170 "Unrecognized operation %s", method.
c_str());
Ptr< SuperpixelLSC > createSuperpixelLSC(InputArray image, int region_size=10, float ratio=0.075f)
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
int last_id
Last object id to allocate.
virtual int getNumberOfSuperpixels() const=0
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void enforceLabelConnectivity(int min_element_size=20)=0
virtual void read(const FileNode &fn)
virtual void getLabelContourMask(OutputArray image, bool thick_line=true) const=0
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...
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.
map< int, Ptr< SuperpixelLSC > > obj_
Object container.
FileNode getFirstTopLevelNode() const
virtual String getDefaultName() const
Global constant definitions.
virtual void iterate(int num_iterations=10)=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.
virtual void getLabels(OutputArray labels_out) const=0