wp1ddraw.m
上传用户:haiyisale
上传日期:2013-01-09
资源大小:3246k
文件大小:5k
源码类别:

波变换

开发平台:

Matlab

  1. function out1 = wp1ddraw(option,win_wptool,in3)
  2. %WP1DDRAW Wavelet packets 1-D drawing manager. 
  3. %   OUT1 = WP1DDRAW(OPTION,WIN_WPTOOL,IN3)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 08-Jun-1999.
  6. %   Copyright 1995-2002 The MathWorks, Inc.
  7. %   $Revision: 1.15 $
  8. % Memory Blocks of stored values.
  9. %================================
  10. % MB2 (main window).
  11. %-------------------
  12. n_wp_utils = 'WP_Utils';
  13. ind_tree_lin  = 1;
  14. ind_tree_txt  = 2;
  15. ind_type_txt  = 3;
  16. ind_sel_nodes = 4;
  17. ind_gra_area  = 5;
  18. ind_nb_colors = 6;
  19. nb2_stored    = 6;
  20. % MB3 (main window).
  21. %-------------------
  22. n_structures = 'Structures';
  23. ind_tree_st  = 1;
  24. ind_data_st  = 2;
  25. nb3_stored   = 2;
  26. % Tag property of objects.
  27. %-------------------------
  28. tag_pop_colm  = 'Txt_PopM';
  29. tag_curtree   = 'Pop_CurTree';
  30. tag_nodact    = 'Pop_NodAct';
  31. tag_axe_t_lin = 'Axe_TreeLines';
  32. tag_axe_sig   = 'Axe_Sig';
  33. tag_lin_sig   = 'Lin_sig';
  34. tag_axe_pack  = 'Axe_Pack';
  35. tag_axe_cfs   = 'Axe_Cfs';
  36. tag_axe_col   = 'Axe_Col';
  37. tag_sli_size  = 'Sli_Size';
  38. tag_sli_pos   = 'Sli_Pos';
  39. % Miscellaneous values.
  40. %----------------------
  41. Col_SigIni  = 'r';
  42. children    = get(win_wptool,'Children');
  43. axe_handles = findobj(children,'flat','type','axes');
  44. uic_handles = findobj(children,'flat','type','uicontrol');
  45. WP_Axe_Tree = findobj(axe_handles,'flat','Tag',tag_axe_t_lin);
  46. WP_Axe_Sig  = findobj(axe_handles,'flat','Tag',tag_axe_sig);
  47. WP_Axe_Pack = findobj(axe_handles,'flat','Tag',tag_axe_pack);
  48. WP_Axe_Cfs  = findobj(axe_handles,'flat','Tag',tag_axe_cfs);
  49. WP_Axe_Col  = findobj(axe_handles,'flat','Tag',tag_axe_col);
  50. WP_Sli_Size = findobj(uic_handles,'Tag',tag_sli_size);
  51. WP_Sli_Pos  = findobj(uic_handles,'Tag',tag_sli_pos);
  52. switch option
  53.     case 'sig'
  54.         % Signal_Anal = in3;
  55.         %------------------
  56.         set([ WP_Axe_Tree,WP_Axe_Cfs,WP_Axe_Sig,WP_Axe_Pack, ...
  57.               WP_Axe_Col,WP_Sli_Size,WP_Sli_Pos],'Visible','on');
  58.         xmin = 1;         xmax = length(in3);
  59.         ymin = min(in3);  ymax = max(in3);
  60.         if ymin==ymax , dy = 0.01; else , dy = (ymax-ymin)/25; end
  61.         ymin = ymin-dy;   ymax = ymax+dy;
  62.         plot(in3,'Color',Col_SigIni,'tag',tag_lin_sig,'Parent',WP_Axe_Sig);
  63.         set(WP_Axe_Sig,'Xlim',[xmin xmax],'Ylim',[ymin ymax],'Tag',tag_axe_sig);
  64.         wtitle(sprintf('Analyzed Signal : length = %.0f',xmax),...
  65.                 'Parent',WP_Axe_Sig);
  66.         wtitle('Decomposition Tree','Parent',WP_Axe_Tree);
  67.         wtitle('Node Action Result','Parent',WP_Axe_Pack);
  68.         set(WP_Axe_Cfs,'Xlim',[xmin xmax]);
  69.         wtitle('Colored Coefficients for Terminal Nodes','Parent',WP_Axe_Cfs);
  70.         pop_colm = findobj(win_wptool,'style','popupmenu',...
  71.                                         'tag',tag_pop_colm);
  72.         col_mode = get(pop_colm,'Value');
  73.         if find(col_mode==[1 2 3 4])
  74.             strlab = ['frequency ordered coefficients'];
  75.         else
  76.             strlab = ['(down -> up) for Cfs <==> (left -> right) in Tree'];
  77.         end
  78.         wsetxlab(WP_Axe_Cfs,strlab);
  79.         NB_ColorsInPal  = wmemtool('rmb',win_wptool,    ...
  80.                                         n_wp_utils,ind_nb_colors);
  81.         image([0 1],[0 1],[1:NB_ColorsInPal],'Parent',WP_Axe_Col);
  82.         set(WP_Axe_Col,...
  83.                 'XTickLabel',[],'YTickLabel',[],...
  84.                 'XTick',[],'YTick',[],'Tag',tag_axe_col);
  85.         wsetxlab(WP_Axe_Col,'Scale of Colors from Min to Max');
  86.     case 'anal'
  87.         pop_handles = findobj(uic_handles,'style','popupmenu');
  88.         pop_curtree = findobj(pop_handles,'Tag',tag_curtree);
  89.         pop_nodact  = findobj(pop_handles,'Tag',tag_nodact);
  90.         % Reading structures.
  91.         %--------------------
  92.         [tree_struct,data_struct] = wmemtool('rmb',win_wptool,n_structures,...
  93.                                                    ind_tree_st,ind_data_st);
  94.         if isa(tree_struct,'wptree')
  95.             wptreeop('input_tree',win_wptool,tree_struct);
  96.         else
  97.             wptreeop('input_tree',win_wptool,tree_struct,data_struct);
  98.         end
  99.         depth = treedpth(tree_struct);
  100.         str_depth = int2str([0:depth]');
  101.         set(pop_curtree,'String',str_depth,'Value',depth+1);
  102.         wtitle('Node Action Result','Parent',WP_Axe_Pack);
  103.         % Setting Dynamic Visualization tool.
  104.         %------------------------------------
  105.         dynvtool('init',win_wptool,...
  106.                         [WP_Axe_Pack],[WP_Axe_Sig,WP_Axe_Cfs],[],[1 0],'','',...
  107.                                                         'wp1dcoor',WP_Axe_Cfs);
  108.         wptreeop('nodact',win_wptool,pop_nodact);
  109.     case 'r_orig'
  110.         out1 = findobj(WP_Axe_Sig,'type','line','tag',tag_lin_sig);
  111.     otherwise
  112.         errargt(mfilename,'Unknown Option','msg');
  113.         error('*');
  114. end