4 * Wrapper for Weksler Olga's GraphCut to Matlab
\r
6 * wrapper by Shai Bagon 2006, contact shai.abgon@weizmann.ac.il or shaibagon@gmail.com
\r
9 #ifndef _GRAPH_CUT_H_
\r
10 #define _GRAPH_CUT_H_
\r
13 #include <tmwtypes.h>
\r
15 /* handle type for graph class */
\r
16 typedef void* GraphHandle;
\r
18 /* we want to verify that the class is valid */
\r
19 #define VALID_CLASS_SIGNITURE 0xabcd0123
\r
21 /* pointer types in 64 bits machines */
\r
23 #define MATLAB_POINTER_TYPE mxUINT64_CLASS
\r
25 #define MATLAB_POINTER_TYPE mxUINT32_CLASS
\r
29 void GetScalar(const mxArray* x, T& scalar)
\r
31 if ( mxGetNumberOfElements(x) != 1 )
\r
32 mexErrMsgIdAndTxt("GraphCut:GetScalar","input is not a scalar!");
\r
33 void *p = mxGetData(x);
\r
34 switch (mxGetClassID(x)) {
\r
38 case mxDOUBLE_CLASS:
\r
39 scalar = *(double*)p;
\r
41 case mxSINGLE_CLASS:
\r
42 scalar = *(float*)p;
\r
48 scalar = *(unsigned char*)p;
\r
51 scalar = *(short*)p;
\r
53 case mxUINT16_CLASS:
\r
54 scalar = *(unsigned short*)p;
\r
59 case mxUINT32_CLASS:
\r
60 scalar = *(unsigned int*)p;
\r
64 scalar = *(int64_T*)p;
\r
66 case mxUINT64_CLASS:
\r
67 scalar = *(uint64_T*)p;
\r
69 #endif /* 64 bits machines */
\r
71 mexErrMsgIdAndTxt("GraphCut:GetScalar","unsupported data type");
\r
75 /* memory allocations - redirect to MATLAB memory menager */
\r
76 void* operator new(size_t size);
\r
77 void* operator new[](size_t size);
\r
78 void operator delete(void* ptr);
\r
79 void operator delete[](void* ptr);
\r
81 #endif /* _GRAPH_CUT_H_ */
\r