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

图形图像处理

开发平台:

Matlab

  1. % pdfbclassify_texture.m
  2. % written by: Duncan Po
  3. % Date: December 3, 2002
  4. % perform texture classification based on contourlets 
  5. % Usage:    kld = pdfbclassify_texture(qimage, qformat, tdb, tdir, mdir, firsttime)
  6. % Inputs:   qimage      - query texture image file name
  7. %           qformat     - format of the query texture image file
  8. %           tdb         - texture database: vector (using cell structure)
  9. %                           of the names of all the texture images
  10. %                           e.g. {'texture1', 'texture2', 'texture3'}
  11. %           tdir        - texture directory: full path of the directory 
  12. %                           that contains the texture images
  13. %           mdir        - model directory: full path of the directory that 
  14. %                           either contains the texture models, or that is
  15. %                           for saving of the texture models
  16. %           firsttime   - set to 1 if this is the first time that this
  17. %                           algorithm is run and no model is available
  18. %                           for the database images, set to 0 otherwise           
  19. % Output:   kld         - the Kublick Liebler distance between the trees
  20. function kld = pdfbclassify_texture(qimage, qformat, tdb, tdir, mdir, firsttime)
  21. N = 8;
  22. NN = 16;
  23. if tdir(end) ~= '/'
  24.     tdir = strcat(tdir, '/');
  25. end;
  26. if mdir(end) ~= '/'
  27.     mdir = strcat(mdir, '/');
  28. end;
  29. mdir = strcat(mdir, '/');
  30. [kld, kld2] = pdfbtestall_imagekld(qimage, qformat, tdb, tdir, mdir, N, firsttime);
  31. [skld2, ind2] = sort(kld2);
  32. ind2 = ind2(1:NN-1);
  33. original = imread(qimage, qformat);
  34. figure;
  35. subplot(4,4,1);
  36. imshow(original);
  37. for ploti = 2:NN
  38.     dbimagenum = floor((ind2(ploti-1)-1)/N)+1;
  39.     dbimage = tdb{dbimagenum};
  40.     dbimagenum = mod(ind2(ploti-1)-1, N)+1;
  41.     file = sprintf('%s%s%02d', tdir, dbimage, dbimagenum);
  42.     qresult = imread(file, 'bmp');
  43.     subplot(4,4,ploti);
  44.     imshow(qresult);
  45. end;