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

图形图像处理

开发平台:

Matlab

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