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

波变换

开发平台:

Matlab

  1. function wp1dutil(option,win_wptool,in3,in4)
  2. %WP1DUTIL Wavelet packets 1-D utilities.
  3. %   WP1DUTIL(OPTION,WIN_WPTOOL,IN3,IN4)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 08-Jan-2001.
  6. %   Copyright 1995-2002 The MathWorks, Inc.
  7. %   $Revision: 1.12 $ $Date: 2002/06/17 12:19:03 $
  8. % Default values.
  9. %----------------
  10. max_lev_anal = 12;
  11. % Memory Blocks of stored values.
  12. %================================
  13. % MB1 (main window).
  14. %-------------------
  15. n_param_anal   = 'WP1D_Par_Anal';
  16. ind_sig_name   = 1;
  17. ind_wav_name   = 2;
  18. ind_lev_anal   = 3;
  19. ind_ent_anal   = 4;
  20. ind_ent_par    = 5;
  21. ind_sig_size   = 6;
  22. ind_act_option = 7;
  23. ind_thr_val    = 8;
  24. nb1_stored     = 8;
  25. % MB2 (main window).
  26. %-------------------
  27. n_wp_utils = 'WP_Utils';
  28. ind_tree_lin  = 1;
  29. ind_tree_txt  = 2;
  30. ind_type_txt  = 3;
  31. ind_sel_nodes = 4;
  32. ind_gra_area  = 5;
  33. ind_nb_colors = 6;
  34. nb2_stored    = 6;
  35. % Tag property of objects.
  36. %-------------------------
  37. tag_m_savesyn = 'Save_Syn';
  38. tag_m_savedec = 'Save_Dec';
  39. tag_pus_anal  = 'Pus_Anal';
  40. tag_pus_deno  = 'Pus_Deno';
  41. tag_pus_comp  = 'Pus_Comp';
  42. tag_pus_btree = 'Pus_Btree';
  43. tag_pus_blev  = 'Pus_Blev';
  44. tag_inittree  = 'Pus_InitTree';
  45. tag_wavtree   = 'Pus_WavTree';
  46. tag_curtree   = 'Pop_CurTree';
  47. tag_nodlab    = 'Pop_NodLab';
  48. tag_nodact    = 'Pop_NodAct';
  49. tag_nodsel    = 'Pus_NodSel';
  50. tag_txt_full  = 'Txt_Full';
  51. tag_pus_full  = ['Pus_Full.1';'Pus_Full.2';'Pus_Full.3';'Pus_Full.4'];
  52. tag_pop_colm  = 'Txt_PopM';
  53. tag_axe_t_lin = 'Axe_TreeLines';
  54. tag_axe_sig   = 'Axe_Sig';
  55. tag_axe_pack  = 'Axe_Pack';
  56. tag_axe_cfs   = 'Axe_Cfs';
  57. tag_axe_col   = 'Axe_Col';
  58. tag_sli_size  = 'Sli_Size';
  59. tag_sli_pos   = 'Sli_Pos';
  60. % Miscellaneous values.
  61. %----------------------
  62. Col_SigIni  = 'r';
  63. children    = get(win_wptool,'Children');
  64. axe_handles = findobj(children,'flat','type','axes');
  65. uic_handles = findobj(children,'flat','type','uicontrol');
  66. pop_handles = findobj(uic_handles,'style','popupmenu');
  67. pus_handles = findobj(uic_handles,'style','pushbutton');
  68. txt_handles  = findobj(uic_handles,'Style','text');
  69. m_files      = wfigmngr('getmenus',win_wptool,'file');
  70. m_savesyn    = findobj(m_files,'Tag',tag_m_savesyn);
  71. m_savedec    = findobj(m_files,'Tag',tag_m_savedec);
  72. pus_anal     = findobj(pus_handles,'Tag',tag_pus_anal);
  73. pus_deno     = findobj(pus_handles,'Tag',tag_pus_deno);
  74. pus_comp     = findobj(pus_handles,'Tag',tag_pus_comp);
  75. pus_inittree = findobj(pus_handles,'Tag',tag_inittree);
  76. pus_wavtree  = findobj(pus_handles,'Tag',tag_wavtree);
  77. pus_btree    = findobj(pus_handles,'Tag',tag_pus_btree);
  78. pus_blev     = findobj(pus_handles,'Tag',tag_pus_blev);
  79. pop_curtree  = findobj(pop_handles,'Tag',tag_curtree);
  80. pop_nodlab   = findobj(pop_handles,'Tag',tag_nodlab);
  81. pop_nodact   = findobj(pop_handles,'Tag',tag_nodact);
  82. for k =1:size(tag_pus_full,1)
  83.     pus_full(k) = (findobj(pus_handles,'Tag',tag_pus_full(k,:)))';
  84. end
  85. pop_colm    = findobj(pop_handles,'Tag',tag_pop_colm);
  86. pus_nodsel  = findobj(pus_handles,'Tag',tag_nodsel);
  87. WP_Axe_Tree = findobj(axe_handles,'flat','Tag',tag_axe_t_lin);
  88. WP_Axe_Sig  = findobj(axe_handles,'flat','Tag',tag_axe_sig);
  89. WP_Axe_Pack = findobj(axe_handles,'flat','Tag',tag_axe_pack);
  90. WP_Axe_Cfs  = findobj(axe_handles,'flat','Tag',tag_axe_cfs);
  91. WP_Axe_Col  = findobj(axe_handles,'flat','Tag',tag_axe_col);
  92. switch option
  93.     case 'clean'
  94.         % in3 = type of loading.
  95.         %-----------------------
  96.         % 'load_sig' , 'load_dec' , 'demo'
  97.         %----------------------------------
  98.         if nargin<4 , in4 = ''; end
  99.         str_btn = 'Analyze';
  100.         cba_btn = ['wp1dmngr(''anal'',' sprintf('%.0f',win_wptool) ');'];
  101.         set(pus_anal,'String',xlate(str_btn),'Callback',cba_btn);
  102.         % Testing first use.
  103.         %-------------------
  104.         active_option = wmemtool('rmb',win_wptool,n_param_anal, ...
  105.                                                         ind_act_option);
  106.         if isempty(active_option) , first = 1; else, first = 0; end
  107.         % End of Cleaning when first is true.
  108.         %------------------------------------
  109.         if first , return; end
  110.         % Setting enable property of objects.
  111.         %------------------------------------
  112.         set([m_savesyn,m_savedec],'Enable','Off');
  113.         cbanapar('enable',win_wptool,'off');
  114.         utentpar('enable',win_wptool,'off');
  115.         set([pus_anal,     pus_deno,       pus_comp,    ...
  116.              pus_inittree, pus_wavtree,                 ...
  117.              pus_btree,    pus_blev,       pop_curtree, ...
  118.              pop_nodlab,   pop_nodact,     pus_nodsel,  ...
  119.              pus_full,     pop_colm                     ...
  120.              ],...
  121.                 'Enable','off'...
  122.                 );
  123.         % Cleaning DynVTool.
  124.         %-------------------
  125.         dynvtool('stop',win_wptool);
  126.         % Cleaning Axes.
  127.         %--------------
  128.         wpfullsi('clean',win_wptool);
  129.         axe_hld = [WP_Axe_Tree,WP_Axe_Cfs,WP_Axe_Pack];
  130.         if ~strcmp(in4,'new_anal')
  131.             axe_hld = [axe_hld , WP_Axe_Sig, WP_Axe_Col];
  132.             cleanaxe(axe_hld);
  133.         else
  134.             xlab    = get(WP_Axe_Cfs,'xlabel');
  135.             strxlab = get(xlab,'String');
  136.             titl    = get(WP_Axe_Cfs,'title');
  137.             strtitl = get(titl,'String');
  138.             cleanaxe(axe_hld);       
  139.             axes(WP_Axe_Cfs)
  140.             wtitle(strtitl,'Parent',WP_Axe_Cfs,'Visible','on');
  141.             wxlabel(strxlab,'Parent',WP_Axe_Cfs,'Visible','off')
  142.         end
  143.         wmemtool('wmb',win_wptool,n_wp_utils,...
  144.                         ind_tree_lin,[],ind_tree_txt,[],ind_sel_nodes,[]);
  145.         % Cleaning GUI.
  146.         %--------------
  147.         set(pop_nodlab,'Value',1,'Userdata',1);
  148.         set(pop_nodact,'Value',1,'Userdata',1);
  149.         if ~strcmp(in4,'new_anal')
  150.             str_lev_data = int2str([1:max_lev_anal]');
  151.             cbanapar('set',win_wptool,...
  152.                 'nam','',             ...
  153.                 'wav','haar',         ...
  154.                 'lev',{'String',str_lev_data,'Value',1});
  155.             utentpar('clean',win_wptool);
  156.         end
  157.     case 'set_gui'
  158.         % in3 = calling option.
  159.         %----------------------
  160.         switch in3
  161.             case 'load_sig'
  162.                 [Sig_Name,Sig_Size] = ...
  163.                         wmemtool('rmb',win_wptool,n_param_anal,...
  164.                                         ind_sig_name,ind_sig_size);
  165.                 Sig_Size  = max(Sig_Size);
  166.                 levm      = wmaxlev(Sig_Size,'haar');
  167.                 levmax    = min(levm,max_lev_anal);
  168.                 str_lev_data = int2str([1:levmax]');
  169.                 cbanapar('set',win_wptool,...
  170.                     'n_s',{Sig_Name,Sig_Size},  ...
  171.                     'lev',{'String',str_lev_data,'Value',min(levmax,3)});
  172.             case {'demo','load_dec'}
  173.                 [Sig_Name,Sig_Size,Wav_Name,Lev_Anal,...
  174.                         Ent_Name,Ent_Par] = ...
  175.                         wmemtool('rmb',win_wptool,n_param_anal,   ...
  176.                                        ind_sig_name,ind_sig_size, ...
  177.                                        ind_wav_name,ind_lev_anal, ...
  178.                                        ind_ent_anal,ind_ent_par);
  179.                 Sig_Size  = max(Sig_Size);
  180.                 levm   = fix(log(Sig_Size)/log(2))-1;
  181.                 levmax = min(levm,max_lev_anal);
  182.                 str_lev_data = int2str([1:levmax]');
  183.                 cbanapar('set',win_wptool,...
  184.                     'n_s',{Sig_Name,Sig_Size}, ...
  185.                     'wav',Wav_Name, ...
  186.                     'lev',{'String',str_lev_data,'Value',Lev_Anal});
  187.                 utentpar('set',win_wptool,'ent',{Ent_Name,Ent_Par});
  188.             case 'anal'
  189.                 Lev_Anal = wmemtool('rmb',win_wptool,n_param_anal,ind_lev_anal);
  190.          end
  191.         switch in3
  192.             case {'load_sig','demo','load_dec'}
  193.                 pos_g = wmemtool('rmb',win_wptool,n_wp_utils,ind_gra_area);
  194.                 [nul, nul, nul, nul, pos_sli_size, pos_sli_pos, nul] = ...
  195.                                 wpposaxe(win_wptool,1,pos_g);
  196.                 sli_handles    = findobj(uic_handles,'style','slider');
  197.                 WP_Slider_Size = findobj(sli_handles,'Tag',tag_sli_size);
  198.                 WP_Slider_Pos  = findobj(sli_handles,'Tag',tag_sli_pos);
  199.                 set(WP_Slider_Size,'Position',pos_sli_size);
  200.                 set(WP_Slider_Pos,'Position',pos_sli_pos);
  201.         end
  202.     case 'enable'
  203.         % in3 = calling option.
  204.         %----------------------
  205.         switch in3
  206.             case {'load_sig','demo','load_dec'}
  207.                 cbanapar('enable',win_wptool,'on');
  208.                 utentpar('enable',win_wptool,'on');
  209.                 set(pus_anal,'Enable','On');
  210.         end
  211.         switch in3
  212.             case {'demo','load_dec','anal','synt'}
  213.                 cbcolmap('enable',win_wptool,'on');
  214.                 set([pus_deno,    pus_comp,     pus_btree,   ...
  215.                      pus_blev,    pus_inittree, pus_wavtree, ...
  216.                      pop_curtree, pop_nodlab,   pop_nodact,  ...
  217.                      pus_nodsel,  pus_full,     pop_colm     ...
  218.                      ],      ...
  219.                      'Enable','on'...
  220.                      );
  221.                 set([m_savesyn , m_savedec],'Enable','on');
  222.             case {'comp','deno'}
  223.                 set([m_files, pus_anal, pus_deno, pus_comp],'Enable','off');
  224.             case {'return_comp','return_deno'}
  225.                 set([m_files, pus_anal, pus_deno, pus_comp],'Enable','on');
  226.         end
  227.     otherwise
  228.         errargt(mfilename,'Unknown Option','msg');
  229.         error('*');
  230. end