| 查看: 343 | 回复: 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->”箭头指针有问题,但我不知道原因。 |
» 猜你喜欢
中!中!中!
已经有3人回复
基于自然哲学类比的风化壳型稀土矿
已经有7人回复
评委有多少概率知道其他专家手中有哪些人的本子?
已经有4人回复
E0414, 我的本子有没有希望?
已经有17人回复
青A35岁以下通知答辩了吗
已经有4人回复
小城的小雨
已经有3人回复
看《给阿ma的情书》有感
已经有5人回复
国自然申请五篇代表作大比拼,感觉这个是最重要的
已经有4人回复
雷雨
已经有3人回复











;
回复此楼