24小时热门版块排行榜    

查看: 346  |  回复: 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一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +3 HEQlVqMTIA7d 2026-08-07 3/150 2026-08-08 03:47 by 6vVgjDL4CnGu
[基金申请] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 KXLV3nuBVBY7 2026-08-07 3/150 2026-08-08 03:27 by 6vVgjDL4CnGu
[基金申请] 基金中了 +14 laoda193707 2026-08-06 14/700 2026-08-08 00:23 by 实验小白ha
[基金申请] 关于filecode +4 布布和一二 2026-08-07 7/350 2026-08-07 22:55 by zhanghaozhu
[基金申请] 娱乐 +6 Tide man 2026-08-03 6/300 2026-08-07 22:40 by 铁帽子农民
[基金申请] 关于代码变化问题,想知道的进来 +9 且听虎啸 2026-08-07 12/600 2026-08-07 21:53 by 理想三旬2025
[基金申请] 听说今天filecode变了 +24 布布和一二 2026-08-06 47/2350 2026-08-07 16:02 by zhiyanjiang
[基金申请] filecode变化情况 +6 布布和一二 2026-08-07 22/1100 2026-08-07 14:45 by 且听虎啸
[论文投稿] 十年后又回来了,论文投稿求助 +4 哈哈114477 2026-08-01 4/200 2026-08-07 14:39 by jgy194592
[基金申请] 大家散了吧,后缀研究没有意义,别浪费时间了,过好目前的每一天,不要焦虑 +5 Tide man 2026-08-06 7/350 2026-08-07 13:11 by 医学老男孩
[基金申请] 关于豆爷回答的JTJC与%2F数量 +4 yang182083 2026-08-06 6/300 2026-08-07 12:43 by 虫友是什么虫
[基金申请] filecode +14 等待解的谜 2026-08-06 19/950 2026-08-07 12:20 by wlwhappy
[基金申请] filecode +8 布布和一二 2026-08-06 11/550 2026-08-06 20:41 by tangpu318
[基金申请] 求各位大神看下 100+6 hpkpkpkp 2026-08-05 33/1650 2026-08-06 14:49 by zhiyanjiang
[基金申请] 影响面上的因素 +8 布布和一二 2026-08-05 11/550 2026-08-06 10:41 by 宝贝虫子
[基金申请] 8月时间戳变的,举个手。玩一下,释放压力 +9 archvillain 2026-08-04 11/550 2026-08-05 20:06 by wlwhappy
[考博] 【2027博士申请】纳米药物递送方向 20+3 13586093586 2026-08-03 4/200 2026-08-05 09:59 by lfy8008
[基金申请] 有没有H口的?有收到消息的吗? +3 超级海虾 2026-08-04 3/150 2026-08-04 17:26 by 学教育滴
[基金申请] 纯娱乐,不喜欢勿喷 +7 Tide man 2026-08-04 10/500 2026-08-04 15:10 by loufangrui
[基金申请] 面上提前没消息,有中的吗 +14 archvillain 2026-08-02 18/900 2026-08-04 14:42 by archvillain
信息提示
请填处理意见