24小时热门版块排行榜    

查看: 353  |  回复: 0

zkj8853

银虫 (小有名气)

[求助] 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->”箭头指针有问题,但我不知道原因。
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zkj8853 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[公派出国] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 ero8OE6tv9cu 2026-09-02 4/200 2026-09-03 03:14 by rM1TE0WVDIIY
[博后之家] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 ero8OE6tv9cu 2026-09-02 6/300 2026-09-02 23:59 by rM1TE0WVDIIY
[基金申请] 为什么资助数各大高校都创新高,自己申请怎么就这么难 +14 Kittylucky 2026-08-27 15/750 2026-09-02 19:35 by liumei0601
[基金申请] 科研人应该花精力去思考如何解决问题,而不是去凝练问题 +7 瞬息宇宙 2026-09-01 14/700 2026-09-02 17:33 by ma0526
[基金申请] 要骂人了,新模版改版就是要淡化问题凝练这种虚的东西,结果有个评委还在说凝练得不够 +9 瞬息宇宙 2026-08-31 17/850 2026-09-02 14:04 by anjeeshine
[基金申请] 基金系统什么内容也没有 30+4 winsaint 2026-08-27 10/500 2026-09-02 11:35 by 大不刘6
[基金申请] 学科评审组评审是指会评吗? +5 瞬息宇宙 2026-08-31 5/250 2026-09-02 10:13 by 雨冰共舞
[基金申请] 面上函评意见出来了,像什么等级? 20+4 Tsingking1 2026-08-27 17/850 2026-09-01 19:51 by 超级无敌华子
[论文投稿] 小白求助 投论文要求的highlights应该如何写 5+3 l1963982152 2026-08-29 4/200 2026-09-01 09:04 by 北京莱茵编辑
[基金申请] 麻烦专家们看看评委们的意见(F口面上) +7 gdd2018 2026-08-28 12/600 2026-09-01 08:32 by 尼古拉斯小虫
[基金申请] 面上意见出来了 +12 黄鸟于飞Chao 2026-08-29 23/1150 2026-08-31 18:57 by 黄鸟于飞Chao
[基金申请] 能否申诉? +7 echo8914667 2026-08-30 8/400 2026-08-31 17:00 by yihongxu
[基金申请] 中青基了要发朋友圈吗? +7 349506619 2026-08-28 7/350 2026-08-31 13:39 by 冼亮淀粉酶
[基金申请] 29号明天会评吗 +4 笨笨唐 2026-08-28 4/200 2026-08-31 09:30 by huixian257
[基金申请] 为什么到现在没收到通知? +5 tannykie 2026-08-29 5/250 2026-08-30 21:05 by purplejack
[基金申请] 有没有仍没收到信息的 +7 德尚中行 2026-08-27 8/400 2026-08-30 20:52 by purplejack
[考博] 找导师 +6 yuanjiabao 2026-08-29 7/350 2026-08-30 14:40 by 生科新手
[基金申请] 我就是申请一个面上项目而已,这评审意见是按照杰青的条件评的吧? +6 gouxfjh 2026-08-28 11/550 2026-08-30 07:57 by gouxfjh
[基金申请] 国自然评审意见 +13 wangmingqi 2026-08-28 19/950 2026-08-29 10:22 by Poppy1104
[基金申请] 2026年叶企孙基金 +4 bud_bud 2026-08-27 7/350 2026-08-29 07:23 by foolishmani
信息提示
请填处理意见