本人原创,请大家参考下,有问题提出或者咨询我。
里面用到的函数都不重要,重要的是mexFunction的写法。这个例子我已经能够成功传出结构体到matlab,并且结构体中含有数组的也成功传出。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#include
using namespace std; /********************************************************************************************************/ /******* Set Parameters Here. *******/ /********************************************************************************************************/ //#define NUMBER_OF_STRUCTS (sizeof(pixelArray)/sizeof(struct pixel)) #define RADIUS 3 // the radius of neighborhood when calculating the length energy #define NUM_CLUSTER 1500 // the number of segments you want #define WEIGHT_LENGTH 5.0 // the weight parameter of the edge energy const int CIELab = 1; // if "1", make use of the Lab color metric; otherwise, use RGB color space /********************************************************************************************************/ unsigned char *pBmpBuf; // pointer to the readin bmp file int bmpWidth; // t