dump_pdfbmodel_to_file.cc
上传用户:l56789
上传日期:2022-02-25
资源大小:2422k
文件大小:2k
源码类别:

图形图像处理

开发平台:

Matlab

  1. //-----------------------------------------------------------------------------
  2. // dump_pdfbmodel_to_file.cc  -  save the pdfb model structure into a file
  3. //
  4. // input arguments: - model - model to save
  5. //                  - filename - name of the file to save model
  6. //                  - levndir - the number of directions in model
  7. //                  - nl - the number of levels in model
  8. //-----------------------------------------------------------------------------
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include "pdfbthmt.hh"
  12. #include "mex.h"
  13. //-----------------------------------------------------------------------------
  14. void mexFunction( int nlhs, mxArray *plhs[], 
  15.   int nrhs, const mxArray *prhs[] )     
  16. {
  17.     double *templevndir;
  18.     int status, filenamelen, *levndir, nl, i;
  19.     char *filename;
  20.     
  21.     /* Check for proper number of arguments */
  22.     
  23.     if (nrhs != 4) { 
  24. mexErrMsgTxt("Wrong number of arguments."); 
  25.     } else if (nlhs > 0) {
  26. mexErrMsgTxt("Too many output arguments."); 
  27.     } 
  28.     filenamelen = (mxGetM(prhs[1]) * mxGetN(prhs[1])) + 1;
  29.     filename = (char*)mxCalloc(filenamelen, sizeof(char)); 
  30.     status = mxGetString(prhs[1], filename, filenamelen);
  31.     if(status != 0) 
  32.       mexWarnMsgTxt("Not enough space. String is truncated.");
  33.     nl = (int)mxGetScalar(prhs[3]);
  34.     levndir = new int[nl];
  35.     templevndir = mxGetPr(prhs[2]);
  36.     for(i = 0; i<nl; i++)
  37.       levndir[i] = (int)(templevndir[i]);
  38.     THMT thmt(prhs[0], levndir);
  39.     thmt.dump_model(filename);
  40.     return;    
  41. }