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

图形图像处理

开发平台:

Matlab

  1. //-----------------------------------------------------------------------------
  2. // pdfbcalc_KLD.cc  -  calculate the Kublick-Liebler distance between 2
  3. //                     contourlet Tying HMT models
  4. //
  5. // input arguments: - model1 - the first THMT model
  6. //                  - model2 - the second THMT model
  7. //     
  8. //-----------------------------------------------------------------------------
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <iostream>
  13. #include <math.h>
  14. #include "tree.hh"
  15. #include "pdfbthmt.hh"
  16. #include "mex.h"
  17. //-----------------------------------------------------------------------------
  18. double pdfbcalc_KLD(const mxArray* model1, const mxArray* model2, int* levndir)
  19. {
  20.     // Read initial model
  21.     THMT thmt1(model1, levndir);
  22.     THMT thmt2(model2, levndir);
  23.     return KLD_upb(thmt1, thmt2);
  24. }
  25. //-----------------------------------------------------------------------------
  26. void mexFunction( int nlhs, mxArray *plhs[], 
  27.   int nrhs, const mxArray *prhs[] )     
  28. {
  29.     double *templevndir, *kldist; 
  30.     int nl, i, *levndir; 
  31.     
  32.     /* Check for proper number of arguments */
  33.     
  34.     if (nrhs != 4) { 
  35. mexErrMsgTxt("Wrong number of input arguments."); 
  36.     } 
  37.     else if (nlhs > 1) {
  38. mexErrMsgTxt("Too many output arguments."); 
  39.     } 
  40.  
  41.     nl = (int)mxGetScalar(prhs[0]);
  42.     levndir = new int[nl];
  43.     templevndir = mxGetPr(prhs[1]);
  44.     for(i = 0; i<nl; i++)
  45.       levndir[i] = (int)(templevndir[i]);
  46.     plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
  47.     kldist = mxGetPr(plhs[0]);
  48.     /* Do the actual computations in a subroutine */
  49.     *kldist = pdfbcalc_KLD(prhs[2], prhs[3] ,levndir);
  50.     return;
  51. }