| 查看: 346 | 回复: 0 | ||
[求助]
VC中mex程序的图像结构体数据传递问题
|
|
typedef unsigned char ubyte; typedef struct ImageGray ImageGray; struct ImageGray { ulong Width; ulong Height; ubyte *Pixmap; }; void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { ImageGray *img; double temp; if( nrhs >=1 ) img = getData( &prhs[0] ); else mexErrMsgTxt("No Input...\n" ;mrows = mxGetM(prhs[0]); ncols = mxGetN(prhs[0]); plhs[0] = mxCreateDoubleMatrix(mrows,ncols, mxREAL); temp = (mxArray *)mxGetData(plhs[0]); temp = Gettemplate(img,100); mxfree(img); if (nlhs==0) mxDestroyArray(plhs[0]); return; } ImageGray *getData( const mxArray **prhs ) { ubyte *pr, *data; int index, number_of_dimensions, total_elements, bytes_to_copy; const int *ldims; ImageGray *img; total_elements = mxGetNumberOfElements(*prhs); pr = (ubyte *)mxGetData(*prhs); for ( index = 0; index < total_elements; index++ ){ *(data+index) = *pr++; } img->Pixmap = data;//整个程序编译连接都没问题,matlab调用该程序,每次运行到这里都中止。 img->Height = dims[0]; img->Width = dims[1]; return img; } *(data+index) = *pr++;调试没问题,屏蔽img->Pixmap = data;后,下面这两行照样出问题:img->Height = dims[0];img->Width = dims[1]; 所以,我觉得可能是“img->”箭头指针有问题,但我不知道原因。 |
» 猜你喜欢
售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急
已经有3人回复
售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急
已经有3人回复
基金中了
已经有14人回复
关于filecode
已经有7人回复
娱乐
已经有6人回复
化学口download_prp&fileCode的固定段好像这几天一直没变,有变的大神么?
已经有4人回复
关于代码变化问题,想知道的进来
已经有12人回复
固定端突然变了,今天
已经有10人回复
听说今天filecode变了
已经有47人回复
filecode与中标关系的预测
已经有3人回复










;
回复此楼
100