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

波变换

开发平台:

Matlab

  1. function varargout = wvdtool(option,varargin)
  2. %WVDTOOL Wavelet display tool.
  3. %   VARARGOUT = WVDTOOL(OPTION,VARARGIN)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 17-Jan-2001.
  6. %   Copyright 1995-2002 The MathWorks, Inc.
  7. %   $Revision: 1.22 $ $Date: 2002/06/17 12:18:39 $
  8. % Test inputs.
  9. %-------------
  10. if nargin==0 , option = 'create'; end
  11. [option,winAttrb] = utguidiv('ini',option,varargin{:});
  12. % MemBloc1 of stored values.
  13. %---------------------------
  14. n_miscella     = 'WvDisp_Misc';
  15. ind_graph_area = 1;
  16. ind_wave_fam   = 2;
  17. ind_wave_nam   = 3;
  18. ind_refinment  = 4;
  19. nb1_stored     = 4;
  20. % Tag property of objects.
  21. %-------------------------
  22. tag_prec_val  = 'Prec_Val';
  23. tag_cmd_frame = 'Cmd_Frame';
  24. tag_display   = 'Display';
  25. tag_pus_inf1  = 'Pus_Inf1';
  26. tag_pus_inf2  = 'Pus_Inf2';
  27. switch option
  28.     case 'create'
  29.         % Get Globals.
  30.         %-------------
  31.         [Def_Txt_Height,Def_Btn_Height,Def_Btn_Width,  ...
  32.          X_Spacing,Y_Spacing,Def_FraBkColor] = ...
  33.             mextglob('get',...
  34.                 'Def_Txt_Height','Def_Btn_Height','Def_Btn_Width', ...
  35.                 'X_Spacing','Y_Spacing','Def_FraBkColor' ...
  36.                 );
  37.         % Window initialization.
  38.         %----------------------
  39.         win_title = 'Wavelet Display';
  40.         [win_loctool,pos_win,win_units,str_numwin,...
  41.                 frame0,pos_frame0,Pos_Graphic_Area,pus_close] = ...
  42.                     wfigmngr('create',win_title,winAttrb,'ExtFig_WDisp',mfilename);
  43.         varargout{1} = win_loctool;
  44. % Add Help for Tool.
  45. %------------------
  46. wfighelp('addHelpTool',win_loctool,'Wavelet Dis&play','WVDI_GUI');
  47. % Add Help Item.
  48. %----------------
  49. wfighelp('addHelpItem',win_loctool,'Available Wavelets','WVDI_FAMILIES');
  50. wfighelp('addHelpItem',win_loctool,'Wavelet Families','WVDI_ADVANCED');
  51. wfighelp('addHelpItem',win_loctool,'Properties of Wavelet Families','UT_WAVELET');
  52. wfighelp('addHelpItem',win_loctool,'Adding Your Own Wavelets','WVDI_NEWWAVE');
  53.         % Begin waiting.
  54.         %---------------
  55.         set(wfindobj('figure'),'Pointer','watch');
  56.         % General parameters initialization.
  57.         %-----------------------------------
  58.         dx = X_Spacing;
  59.         dy = Y_Spacing; dy2 = 2*dy;
  60.         d_txt = (Def_Btn_Height-Def_Txt_Height);
  61.         % Position property of objects.
  62.         %------------------------------
  63.         xlocINI      = pos_frame0([1 3]);
  64.         ybottomINI   = pos_win(4)-1.5*Def_Btn_Height-dy2;
  65.         y_low        = ybottomINI-2*Def_Btn_Height;
  66.         x_left       = pos_frame0(1)+2*dx;
  67.         pos_prec_txt = [x_left, y_low+d_txt/2, Def_Btn_Width, Def_Txt_Height];
  68.         xleftB       = x_left+Def_Btn_Width+dx;
  69.         pos_prec_val = [xleftB , y_low , Def_Btn_Width , Def_Btn_Height];
  70.         wpop         = 3*(pos_frame0(3)-4*dx)/4;
  71. xborder      = (pos_frame0(3)-wpop)/2;
  72.         xpop         = pos_frame0(1)+xborder;
  73.         y_low        = pos_prec_txt(2)-5*Def_Btn_Height;
  74.         pos_display  = [xpop, y_low, wpop, 2*Def_Btn_Height];
  75.         y_low        = pos_display(2)-3*Def_Btn_Height;
  76.         pos_inf_txt  = [x_left, y_low, 2.5*Def_Btn_Width, Def_Btn_Height];
  77.         pos_pus_inf1    = pos_display;
  78. pos_pus_inf1(1) = pos_pus_inf1(1)-xborder/2;
  79. pos_pus_inf1(3) = pos_pus_inf1(3)+xborder;
  80.         pos_pus_inf1(2) = pos_inf_txt(2)-2*Def_Btn_Height-dy;
  81.         pos_pus_inf2    = pos_pus_inf1;
  82.         pos_pus_inf2(2) = pos_pus_inf1(2)-3*Def_Btn_Height;
  83.         % String property of objects.
  84.         %----------------------------
  85.         str_display  = 'Display';
  86.         str_inf_txt  = 'Information on:';
  87.         str_inf1     = 'Haar Family (HAAR)';
  88.         str_inf2     = 'All Wavelet Families';
  89.         str_prec_txt = 'Refinement';
  90.         str_prec_val = ['5 ' ; '6 ' ; '7 ' ; '8 ' ; '9 ' ; '10' ; '11' ; '12' ];
  91.         % Command part construction of the window.
  92.         %-----------------------------------------
  93.         utanapar('create',win_loctool, ...
  94.                  'xloc',xlocINI,'bottom',ybottomINI,...
  95.                  'datflag',0,'levflag',0,...
  96.                  'wtype','all' ...
  97.                  );
  98.         comFigProp = {'Parent',win_loctool,'Unit',win_units};
  99.         comPopProp = {comFigProp{:},'Style','Popup'};
  100.         comPusProp = {comFigProp{:},'Style','Pushbutton'};
  101.         comTxtProp = {comFigProp{:},'Style','Text', ...
  102.            'HorizontalAlignment','left','Backgroundcolor',Def_FraBkColor};
  103.         Tooltip      = 'The wavelet is computed on a 2^Refinement grid';
  104.         txt_prec_txt = uicontrol(comTxtProp{:}, ...
  105.                                  'Position',pos_prec_txt,...
  106.                                  'String',str_prec_txt,...
  107.                                  'Tooltip',Tooltip ...
  108.                                   );
  109.         pop_prec_val = uicontrol(comPopProp{:},...
  110.                                  'Position',pos_prec_val,...
  111.                                  'String',str_prec_val,...
  112.                                  'Value',4,...
  113.                                  'Tooltip',Tooltip,...
  114.                                  'Tag',tag_prec_val...
  115.                                  );
  116.         pus_display  = uicontrol(comPusProp{:},...
  117.                                  'Position',pos_display,...
  118.                                  'String',xlate(str_display),...
  119.                                  'Tag',tag_display...
  120.                                  );
  121.         txt_inf_txt  = uicontrol(comTxtProp{:}, ...
  122.                                  'Position',pos_inf_txt,...
  123.                                  'String',str_inf_txt...
  124.                                  );
  125.         pus_inf1     = uicontrol(comPusProp{:},...
  126.                                  'Position',pos_pus_inf1,...
  127.                                  'String',xlate(str_inf1),...
  128.  'Max',2,...
  129.                                  'Tag',tag_pus_inf1...
  130.                                  );
  131.         pus_inf2     = uicontrol(comPusProp{:},...
  132.                                  'Position',pos_pus_inf2,...
  133.                                  'String',xlate(str_inf2),...
  134.                                  'Tag',tag_pus_inf2...
  135.                                  );
  136.         % Callbacks update.
  137.         %------------------
  138.         utanapar('set_cba_num',win_loctool,[pus_display]);
  139.         [pop_fam,pop_num] = utanapar('handles',win_loctool,'fam','num');
  140.         cb_fam = get(pop_fam,'Callback');
  141.         cb_num = get(pop_num,'Callback');
  142.         cba_upd_fam = [mfilename '(''upd_fam'',' str_numwin ');'];
  143.         cba_update  = [mfilename '(''new'',' str_numwin ');'];
  144.         cba_draw_1d = [mfilename '(''draw1d'',' str_numwin ');'];
  145.         cba_inf1    = [mfilename '(''inf1'',' str_numwin ');'];
  146.         cba_inf2    = [mfilename '(''inf2'',' str_numwin ');'];
  147.         set(pop_fam,'Callback',[cb_fam , cba_upd_fam]);
  148.         set(pop_num,'Callback',[cb_num , cba_update]);
  149.         set(pop_prec_val,'Callback',cba_update);
  150.         set(pus_display,'Callback',cba_draw_1d);
  151.         set(pus_inf1,'Callback',cba_inf1);
  152.         set(pus_inf2,'Callback',cba_inf2);
  153.         % Setting units to normalized.
  154.         %-----------------------------
  155.         Pos_Graphic_Area = Pos_Graphic_Area./[pos_win(3:4),pos_win(3:4)];
  156.         set(findobj(win_loctool,'Units','pixels'),'Units','normalized');
  157. % Add Context Sensitive Help (CSHelp).
  158. %-------------------------------------
  159. hdl_WVDI_GUI = [txt_prec_txt,pop_prec_val];
  160. wfighelp('add_ContextMenu',win_loctool,hdl_WVDI_GUI,'WVDI_GUI');
  161. %-------------------------------------
  162.         % Memory for stored values.
  163.         %--------------------------
  164.         wmemtool('ini',win_loctool,n_miscella,nb1_stored);
  165.         wmemtool('wmb',win_loctool,n_miscella,...
  166.                        ind_graph_area,Pos_Graphic_Area,...
  167.                        ind_wave_fam,'haar', ...
  168.                        ind_wave_nam,'haar', ...
  169.                        ind_refinment,0      ...
  170.                        );
  171.         % End waiting.
  172.         %-------------
  173.         set(wfindobj('figure'),'Pointer','arrow');
  174.     case 'upd_fam'
  175.         %**********************************************************%
  176.         %** OPTION = 'upd_fam' -  UPDATE OF THE WAVELET FAMILY   **%
  177.         %**********************************************************%
  178.         win_loctool = varargin{1};
  179.         new = wvdtool('new',win_loctool);
  180.         if new==0 , return; end
  181.         % Handles of tagged objects.
  182.         %---------------------------
  183.         pus_handles = findobj(win_loctool,'Style','pushbutton');
  184.         pus_inf1    = findobj(pus_handles,'Tag',tag_pus_inf1);
  185.         % Test family and Set visible on or off the wavelet number if exists.
  186.         %--------------------------------------------------------------------
  187.         wav_nam = cbanapar('get',win_loctool,'wav');
  188.         [wav_fn,wav_fsn,tabNums] = wavemngr('fields',wav_nam,'fn','fsn','tabNums');
  189.         if size(tabNums,1)<2 ,add = ' wavelet'; else , add = ' wavelets'; end
  190. strPush = [wav_fn ' Family (' upper(wav_fsn) ')' ];
  191.         set(pus_inf1,'String',strPush);
  192.     case 'inf1'
  193.         %*****************************************%
  194.         %** OPTION = 'inf1' - LOCAL INFORMATION **%
  195.         %*****************************************%
  196.         win_loctool = varargin{1};
  197.         % Getting wavelet.
  198.         %-----------------
  199.         wav_nam = cbanapar('get',win_loctool,'wav');
  200.         wav_fam = wavemngr('fam_num',wav_nam);
  201.         infotxt = [deblankl(wav_fam) 'info.m'];
  202.         [old_info,fig] = whelpfun('getflag');
  203.         if ~isempty(old_info) & strcmp(infotxt,old_info)
  204.             figure(fig); return;
  205.         end
  206.         % Waiting message.
  207.         %-----------------
  208.         wwaiting('msg',win_loctool,'Wait ... loading');
  209.         [str_inf,fid] = wreadinf(infotxt,'noerror');
  210.         if fid==-1
  211.             msg = sprintf('File %s not found !', infotxt);
  212.             errargt(mfilename,msg,'msg');
  213.             wwaiting('off',win_loctool);
  214.             return
  215.         else
  216.             dim     = size(str_inf);
  217.             rowfam  = str_inf(1,:);
  218.             str_inf = str_inf(2:dim(1),:);
  219.             col = 1;
  220.             while all(str_inf(:,col)==' ') , col = col+1; end
  221.             blk  = ' ' ;
  222.             str_inf = [rowfam ; ...
  223.                        str_inf(:,col:dim(2)) blk*ones(dim(1)-1,col-1) ];
  224.         end
  225.         ftnsize = wmachdep('fontsize','winfo');
  226.         whelpfun('create',str_inf,infotxt,ftnsize);
  227.         % End waiting.
  228.         %-------------
  229.         wwaiting('off',win_loctool);
  230.     case 'inf2'
  231.         %*****************************************%
  232.         %** OPTION = 'inf2' - LOCAL INFORMATION **%
  233.         %*****************************************%
  234.         win_loctool = varargin{1};
  235.         % Handles of tagged objects.
  236.         %---------------------------
  237.         infotxt        = 'infowave.m';
  238.         [old_info,fig] = whelpfun('getflag');
  239.         if ~isempty(old_info) & strcmp(infotxt,old_info)
  240.             figure(fig); return;
  241.         end
  242.         % Waiting message.
  243.         %-----------------
  244.         wwaiting('msg',win_loctool,'Wait ... loading');
  245.         [str_inf,fid]   = wreadinf(infotxt,'noerror');
  246.         if fid==-1
  247.             msg = sprintf('File %s not found !', infotxt);
  248.             errargt(mfilename,msg,'msg');
  249.             wwaiting('off',win_loctool);
  250.             return
  251.         end
  252.         ftnsize = wmachdep('fontsize','winfo');
  253.         whelpfun('create',str_inf,infotxt,ftnsize);
  254.         % End waiting.
  255.         %-------------
  256.         wwaiting('off',win_loctool);
  257.     case 'draw1d'
  258.         %************************************************%
  259.         %** OPTION = 'draw1d' - DRAW AXES IN 1D        **%
  260.         %************************************************%
  261.         win_loctool = varargin{1};
  262.         [new,Wave_Fam,Wave_Nam,prec_val] = wvdtool('new',win_loctool);
  263.         if new==0 , return; end
  264.         % Waiting message.
  265.         %-----------------
  266.         wwaiting('msg',win_loctool,'Wait ... computing');
  267.         % Handles of tagged objects.
  268.         %---------------------------
  269.         fra_handles = findobj(win_loctool,'Style','frame');
  270.         hdl_frame0  = findobj(fra_handles,'Tag',tag_cmd_frame);
  271.         % Update parameters selection before drawing.
  272.         %-------------------------------------------
  273.         wmemtool('wmb',win_loctool,n_miscella, ...
  274.                        ind_wave_fam,Wave_Fam,  ...
  275.                        ind_wave_nam,Wave_Nam,  ...
  276.                        ind_refinment,prec_val  ...
  277.                        );
  278.         % General graphical parameters initialization.
  279.         %--------------------------------------------
  280.         pos_g_area     = wmemtool('rmb',win_loctool,n_miscella,ind_graph_area) ;
  281.         pos_hdl_frame0 = get(hdl_frame0,'Position');
  282.         win_units      = 'normalized';
  283.         pos_win        = get(win_loctool,'Position');
  284.         bdx            = 0.08*pos_win(3);
  285.         bdy            = 0.09*pos_win(4);
  286.         bdy_d          = bdy;
  287.         bdy_u          = bdy;
  288.         bdyl           = pos_g_area(2)+bdy_d;
  289.         w_graph        = pos_hdl_frame0(1);
  290.         h_graph        = pos_g_area(4);
  291.         % Computing and displaying wavelets and filters.
  292.         %-----------------------------------------------
  293.         wtype = wavemngr('type',Wave_Nam);
  294.         commonAxesProp = {...
  295.            'Parent',win_loctool, ...
  296.            'Units',win_units,    ...
  297.            'DrawMode','Fast',    ...
  298.            'Box','On'            ...
  299.            };
  300.         stemCOL = wtbutils('colors','wfilters');
  301.         switch wtype
  302.             case 1
  303.                 str_wintitle = [Wave_Fam ' Wavelet --> ' Wave_Nam];
  304.                 [phi,psi,xVal] = wavefun(Wave_Nam,prec_val);
  305.                 [Lo_D,Hi_D,Lo_R,Hi_R] = wfilters(Wave_Nam);
  306.                 xaxis   = [min(xVal)  max(xVal)];
  307.                 xaxis_f = [0          length(Lo_D)-1];
  308.                 xVal_f  = xaxis_f(1):xaxis_f(2);
  309.                 nb      = 1;
  310.                 len     = length(xVal_f);
  311.                 while len>10
  312.                     nb = 2*nb;
  313.                     len = len/nb;
  314.                 end
  315.                 tics    = 0:nb:length(xVal_f);
  316.                 xlabs   = int2str(tics');
  317.                 yaxis   = [min(min(phi),min(psi))     max(max(phi),max(psi))];
  318.                 ecart   = abs(yaxis(2)-yaxis(1))/20;
  319.                 yaxis(1) = yaxis(1)-ecart;
  320.                 yaxis(2) = yaxis(2)+ecart;
  321.                 yaxis_r = [min(min(Lo_R),min(Hi_R))   max(max(Lo_R),max(Hi_R))];
  322.                 yaxis_d = [min(min(Lo_D),min(Hi_D))   max(max(Lo_D),max(Hi_D))];
  323.                 h_axe_wave = (h_graph-2*bdy-bdy_d-bdy_u)/2;
  324.                 h_axe_filt = h_axe_wave/2;
  325.                 w_axe      = (w_graph-3*bdx)/2;
  326.                 pos_phi  = [ bdx,...
  327.                              bdyl+2*bdy+2*h_axe_filt,...
  328.                              w_axe,h_axe_wave ];
  329.                 pos_psi  = [ 2*bdx+w_axe,...
  330.                              bdyl+2*bdy+2*h_axe_filt,...
  331.                              w_axe,h_axe_wave ];
  332.                 pos_Lo_D = [ bdx,...
  333.                              bdyl+bdy+h_axe_filt,...
  334.                              w_axe,h_axe_filt ];
  335.                 pos_Lo_R = [ bdx,...
  336.                               bdyl,w_axe,h_axe_filt ];
  337.                 pos_Hi_D = [ 2*bdx+w_axe,...
  338.                              bdyl+bdy+h_axe_filt,...
  339.                              w_axe,h_axe_filt ];
  340.                 pos_Hi_R = [ 2*bdx+w_axe,bdyl,w_axe,h_axe_filt ];
  341.                 axeProp  = {commonAxesProp{:},'Position',pos_phi};
  342.                 axeTitle = 'Scaling function phi';
  343.                 axe_phi  = plotYval(xVal,phi,axeProp,'r',axeTitle);
  344.                 axeProp  = {commonAxesProp{:},'Position',pos_psi};
  345.                 axeTitle = 'Wavelet function psi';
  346.                 axe_psi  = plotYval(xVal,psi,axeProp,'g',axeTitle);
  347.                 axe_Lo_D = axes(commonAxesProp{:},'Position',pos_Lo_D);
  348.                 wdstem(axe_Lo_D,xVal_f,Lo_D,stemCOL,1);
  349.                 set(axe_Lo_D,...
  350.                     'Ylim',yaxis_d,            ...
  351.                     'Xlim',xaxis_f,            ...
  352.                     'Box','On',                ...
  353.                     'XTicklabelMode','manual', ...
  354.                     'XTick',tics,              ...
  355.                     'XTickLabel',xlabs         ...
  356.                     );
  357.                 wtitle('Decomposition low-pass filter','Parent',axe_Lo_D);
  358.                 axe_Lo_R = axes(commonAxesProp{:},'Position',pos_Lo_R);
  359.                 wdstem(axe_Lo_R,xVal_f,Lo_R,stemCOL,1);
  360.                 set(axe_Lo_R,...
  361.                     'Ylim',yaxis_r,            ...
  362.                     'Xlim',xaxis_f,            ...
  363.                     'Box','On',                ...
  364.                     'XTicklabelMode','manual', ...
  365.                     'XTick',tics,              ...
  366.                     'XTickLabel',xlabs         ...
  367.                     );
  368.                 wtitle('Reconstruction low-pass filter','Parent',axe_Lo_R);
  369.                 axe_Hi_D = axes(commonAxesProp{:},'Position',pos_Hi_D);
  370.                 wdstem(axe_Hi_D,xVal_f,Hi_D,stemCOL,1);
  371.                 set(axe_Hi_D,...
  372.                     'Ylim',yaxis_d,            ...
  373.                     'Xlim',xaxis_f,            ...
  374.                     'Box','On',                ...
  375.                     'XTicklabelMode','manual', ...
  376.                     'XTick',tics,              ...
  377.                     'XTickLabel',xlabs         ...
  378.                     );
  379.                 wtitle('Decomposition high-pass filter','Parent',axe_Hi_D);
  380.                 axe_Hi_R = axes(commonAxesProp{:},'Position',pos_Hi_R);
  381.                 wdstem(axe_Hi_R,xVal_f,Hi_R,stemCOL,1);
  382.                 set(axe_Hi_R,...
  383.                     'Ylim',yaxis_r,            ...
  384.                     'Xlim',xaxis_f,            ...
  385.                     'Box','On',                ...
  386.                     'XTicklabelMode','manual', ...
  387.                     'XTick',tics,              ...
  388.                     'XTickLabel',xlabs         ...
  389.                     );
  390.                 wtitle('Reconstruction high-pass filter','Parent',axe_Hi_R);
  391.                 axe_cmd = [axe_phi axe_psi];
  392.                 axe_act = [axe_Lo_D axe_Hi_D axe_Lo_R axe_Hi_R];
  393.             case 2
  394.                 [phi1,psi1,phi2,psi2,xVal] = wavefun(Wave_Nam,prec_val);
  395.                 [Lo_D,Hi_D,Lo_R,Hi_R]  = wfilters(Wave_Nam);
  396.                 xaxis   = [min(xVal)    max(xVal)];
  397.                 xaxis_f = [0            length(Lo_D)-1];
  398.                 xVal_f  = 0:xaxis_f(2);
  399.                 nb      = 1;
  400.                 len     = length(xVal_f);
  401.                 while len>10
  402.                     nb = 2*nb;
  403.                     len = len/nb;
  404.                 end
  405.                 tics    = 0:nb:length(xVal_f);
  406.                 xlabs   = int2str(tics');
  407.                 yaxis1  = [min(min(phi1),min(psi1))   max(max(phi1),max(psi1))];
  408.                 ecart   = abs(yaxis1(2)-yaxis1(1))/20;
  409.                 yaxis1(1) = yaxis1(1)-ecart;
  410.                 yaxis1(2) = yaxis1(2)+ecart;
  411.                 yaxis2  = [min(min(phi2),min(psi2))   max(max(phi2),max(psi2))];
  412.                 ecart   = abs(yaxis2(2)-yaxis2(1))/20;
  413.                 yaxis2(1) = yaxis2(1)-ecart;
  414.                 yaxis2(2) = yaxis2(2)+ecart;
  415.                 yaxis_r = [min(min(Lo_R),min(Hi_R)) max(max(Lo_R),max(Hi_R))];
  416.                 yaxis_d = [min(min(Lo_D),min(Hi_D)) max(max(Lo_D),max(Hi_D))];
  417.                 str_wintitle = ['Biorthogonal Wavelet --> ' Wave_Nam];
  418.                 h_axe_wave = 2*(h_graph-3*bdy-bdy_d-bdy_u)/6;
  419.                 h_axe_filt = (h_graph-3*bdy-bdy_d-bdy_u)/6;
  420.                 w_axe      = (w_graph-3*bdx)/2;
  421.                 pos_phi1 = [ bdx,...
  422.                              bdyl+3*bdy+2*h_axe_filt+h_axe_wave,...
  423.                              w_axe,h_axe_wave];
  424.                 pos_phi2 = [ bdx,...
  425.                              bdyl+bdy+h_axe_filt,...
  426.                              w_axe,h_axe_wave];
  427.                 pos_psi1 = [ 2*bdx+w_axe,...
  428.                              bdyl+3*bdy+2*h_axe_filt+h_axe_wave,...
  429.                              w_axe,h_axe_wave];
  430.                 pos_psi2 = [ 2*bdx+w_axe,...
  431.                              bdyl+bdy+h_axe_filt,...
  432.                              w_axe,h_axe_wave];
  433.                 pos_Lo_D = [ bdx,...
  434.                              bdyl+2*bdy+h_axe_filt+h_axe_wave,...
  435.                              w_axe,h_axe_filt];
  436.                 pos_Lo_R = [ bdx,bdyl,w_axe,h_axe_filt];
  437.                 pos_Hi_D = [ 2*bdx+w_axe,...
  438.                               bdyl+2*bdy+h_axe_filt+h_axe_wave,...
  439.                               w_axe,h_axe_filt];
  440.                 pos_Hi_R = [ 2*bdx+w_axe,bdyl,w_axe,h_axe_filt];
  441.                 axeProp  = {commonAxesProp{:},'Position',pos_phi1};
  442.                 axeTitle = 'Decomposition scaling function phi';
  443.                 axe_phi1 = plotYval(xVal,phi1,axeProp,'r',axeTitle);
  444.                 axeProp  = {commonAxesProp{:},'Position',pos_phi2};
  445.                 axeTitle = 'Reconstruction scaling function phi';
  446.                 axe_phi2 = plotYval(xVal,phi2,axeProp,'r',axeTitle);
  447.                 axeProp  = {commonAxesProp{:},'Position',pos_psi1};
  448.                 axeTitle = 'Decomposition wavelet function psi';
  449.                 axe_psi1 = plotYval(xVal,psi1,axeProp,'g',axeTitle);
  450.                 axeProp  = {commonAxesProp{:},'Position',pos_psi2};
  451.                 axeTitle = 'Reconstruction wavelet function psi';
  452.                 axe_psi2 = plotYval(xVal,psi2,axeProp,'g',axeTitle);
  453.                 axe_Lo_D = axes(commonAxesProp{:},'Position',pos_Lo_D);
  454.                 wdstem(axe_Lo_D,xVal_f,Lo_D,stemCOL,1);
  455.                 set(axe_Lo_D,...
  456.                     'Ylim',yaxis_d,...
  457.                     'Xlim',xaxis_f,...
  458.                     'Box','On',...
  459.                     'XTicklabelMode','manual',...
  460.                     'XTick',tics,...
  461.                     'XTickLabel',xlabs...
  462.                     );
  463.                 wtitle('Decomposition low-pass filter','Parent',axe_Lo_D);
  464.                 axe_Lo_R = axes(commonAxesProp{:},'Position',pos_Lo_R);
  465.                 wdstem(axe_Lo_R,xVal_f,Lo_R,stemCOL,1);
  466.                 set(axe_Lo_R,...
  467.                     'Ylim',yaxis_r,...
  468.                     'Xlim',xaxis_f,...
  469.                     'Box','On',...
  470.                     'XTicklabelMode','manual',...
  471.                     'XTick',tics,...
  472.                     'XTickLabel',xlabs...
  473.                     );
  474.                 wtitle('Reconstruction low-pass filter','Parent',axe_Lo_R);
  475.                 axe_Hi_D = axes(commonAxesProp{:},'Position',pos_Hi_D);
  476.                 wdstem(axe_Hi_D,xVal_f,Hi_D,stemCOL,1);
  477.                 set(axe_Hi_D,...
  478.                     'Ylim',yaxis_d,...
  479.                     'Xlim',xaxis_f,...
  480.                     'Box','On',...
  481.                     'XTicklabelMode','manual',...
  482.                     'XTick',tics,...
  483.                     'XTickLabel',xlabs...
  484.                     );
  485.                 wtitle('Decomposition high-pass filter','Parent',axe_Hi_D);
  486.                 axe_Hi_R = axes(commonAxesProp{:},'Position',pos_Hi_R);
  487.                 wdstem(axe_Hi_R,xVal_f,Hi_R,stemCOL,1);
  488.                 set(axe_Hi_R,...
  489.                     'Ylim',yaxis_r,...
  490.                     'Xlim',xaxis_f,...
  491.                     'Box','On',...
  492.                     'XTicklabelMode','manual',...
  493.                     'XTick',tics,...
  494.                     'XTickLabel',xlabs...
  495.                     );
  496.                 wtitle('Reconstruction high-pass filter','Parent',axe_Hi_R);
  497.                 axe_cmd = [axe_phi1 axe_phi2 axe_psi1 axe_psi2];
  498.                 axe_act = [axe_Lo_D axe_Hi_D axe_Lo_R axe_Hi_R];
  499.             case 3
  500.                 str_wintitle   = [Wave_Fam '  Wavelet --> ' Wave_Nam];
  501.                 [phi,psi,xVal] = wavefun(Wave_Nam,prec_val);
  502.                 h_axe   = h_graph-bdy_d-bdy_u;
  503.                 w_axe   = (w_graph-3*bdx)/2;
  504.                 pos_phi = [bdx,bdyl,w_axe,h_axe];
  505.                 pos_psi = [2*bdx+w_axe,bdyl,w_axe,h_axe];
  506.                 axeProp  = {commonAxesProp{:},'Position',pos_phi};
  507.                 axeTitle = 'Scaling function phi';
  508.                 axe_phi  = plotYval(xVal,phi,axeProp,'r',axeTitle);
  509.                 axeProp  = {commonAxesProp{:},'Position',pos_psi};
  510.                 axeTitle = 'Wavelet function psi';
  511.                 axe_psi  = plotYval(xVal,psi,axeProp,'g',axeTitle);
  512.                 axe_cmd = [axe_phi axe_psi];
  513.                 axe_act = [];
  514.             case 4
  515.                 str_wintitle = [Wave_Fam '  Wavelet --> ' Wave_Nam];
  516.                 [psi,xVal]   = wavefun(Wave_Nam,prec_val);
  517.                 h_axe   = h_graph-bdy_d-bdy_u;
  518.                 w_axe   = w_graph-2*bdx;
  519.                 pos_psi = [bdx,bdyl,w_axe,h_axe];
  520.                 axeProp  = {commonAxesProp{:},'Position',pos_psi};
  521.                 axeTitle = 'Wavelet function psi';
  522.                 axe_psi  = plotYval(xVal,psi,axeProp,'g',axeTitle);
  523.                 axe_cmd = axe_psi;
  524.                 axe_act = [];
  525.             case 5
  526.                 str_wintitle = [Wave_Fam '  Wavelet --> ' Wave_Nam];
  527.                 [psi,xVal] = wavefun(Wave_Nam,prec_val);
  528.                 psiAbs = abs(psi);
  529.                 psiAng = angle(psi);
  530.                 h_axe  = (h_graph-bdy_d-bdy_u-bdy)/2;
  531.                 w_axe  = (w_graph-3*bdx)/2;
  532.                 pos_abs = [bdx,bdyl,w_axe,h_axe];
  533.                 pos_ang = [2*bdx+w_axe,bdyl,w_axe,h_axe];
  534.                 y_axe   = bdyl+h_axe+bdy;
  535.                 pos_rea = [bdx,y_axe,w_axe,h_axe];
  536.                 pos_ima = [2*bdx+w_axe,y_axe,w_axe,h_axe];
  537.                 yVal     = real(psi);
  538.                 axeProp  = {commonAxesProp{:},'Position',pos_rea};
  539.                 axeTitle = 'Real part of function psi';
  540.                 axe_rea  = plotYval(xVal,yVal,axeProp,'r',axeTitle);
  541.                 yVal     = imag(psi);
  542.                 axeProp  = {commonAxesProp{:},'Position',pos_ima};
  543.                 axeTitle = 'Imaginary part of function psi';
  544.                 axe_ima  = plotYval(xVal,yVal,axeProp,'g',axeTitle);
  545.                 yVal     = abs(psi);
  546.                 axeProp  = {commonAxesProp{:},'Position',pos_abs};
  547.                 axeTitle = 'Modulus of function psi';
  548.                 axe_abs  = plotYval(xVal,yVal,axeProp,'r',axeTitle);
  549.                 yVal     = angle(psi);
  550.                 axeProp  = {commonAxesProp{:},'Position',pos_ang};
  551.                 axeTitle = 'Angle of function psi';
  552.                 axe_ang  = plotYval(xVal,yVal,axeProp,'g',axeTitle);
  553.  
  554.                 axe_cmd = [axe_rea axe_ima axe_abs axe_ang];
  555.                 axe_act = [];
  556.         end
  557.         % Display status line.
  558.         %---------------------
  559.         wfigtitl('string',win_loctool,str_wintitle,'on');
  560.         % Axes attachment.
  561.         %-----------------
  562.         dynvtool('init',win_loctool,[],axe_cmd,axe_act,[0 0]);
  563.         % Setting units to normalized.
  564.         %-----------------------------
  565.         set(findobj(win_loctool,'Units','pixels'),'Units','normalized');
  566.         % End waiting.
  567.         %-------------
  568.         wwaiting('off',win_loctool);
  569.     case 'new'
  570.         %*************************************************%
  571.         %** OPTION = 'new' -  test drawing parameters   **%
  572.         %*************************************************%
  573.         win_loctool = varargin{1};
  574.         % Handles of tagged objects.
  575.         %---------------------------
  576.         pop_handles  = findobj(win_loctool,'Style','popupmenu');
  577.         pop_prec_val = findobj(pop_handles,'Tag',tag_prec_val);
  578.         % Test Main parameters selection before drawing.
  579.         %-----------------------------------------------
  580.         Wave_Nam = cbanapar('get',win_loctool,'wav');
  581.         Wave_Fam = wavemngr('fam_num',Wave_Nam);
  582.         prec_val = get(pop_prec_val,'Value')+4;
  583.         [wfam,wnam,raf] = wmemtool('rmb',win_loctool,n_miscella,...
  584.                                 ind_wave_fam,ind_wave_nam,ind_refinment);
  585.         if raf~=prec_val | ~strcmp(wnam,Wave_Nam) | ~strcmp(wfam,Wave_Fam)
  586.             varargout = {1,Wave_Fam,Wave_Nam,prec_val};
  587.         else
  588.             varargout = {0,Wave_Fam,Wave_Nam,prec_val};
  589.             return
  590.         end
  591.         % Setting refinment to 0 (as flag).
  592.         %----------------------------------
  593.         wmemtool('wmb',win_loctool,n_miscella,ind_refinment,0);
  594.         % Cleaning the graphical part.
  595.         %-----------------------------
  596.         dynvtool('stop',win_loctool);
  597.         axe_handles = findobj(get(win_loctool,'Children'),'flat', ...
  598.                               'type','axes','visible','on');
  599.         delete(axe_handles);
  600.         wfigtitl('vis',win_loctool,'off');
  601.     case 'demo'
  602.         %*******************************************%
  603.         %** OPTION = 'demo' -  for DEMOS or TESTS **%
  604.         %*******************************************%
  605.         win_loctool = varargin{1};
  606.         Wave_Nam    = varargin{2};
  607.         % Handles of tagged objects.
  608.         %---------------------------
  609.         children     = get(win_loctool,'Children');
  610.         uic_handles  = findobj(children,'flat','type','uicontrol');
  611.         pop_handles  = findobj(uic_handles,'Style','popupmenu');
  612.         pop_prec_val = findobj(pop_handles,'Tag',tag_prec_val);
  613.         pus_handles  = findobj(uic_handles,'Style','pushbutton');
  614.         pus_inf1     = findobj(pus_handles,'Tag',tag_pus_inf1);
  615.         cbanapar('set',win_loctool,'wav',Wave_Nam);
  616.         [Wave_Fam,tabNums] = wavemngr('fields',Wave_Nam,'fsn','tabNums');
  617.         if nargin==4
  618.             set(pop_prec_val,'Value',varargin{3});
  619.         end
  620.         new = wvdtool('new',win_loctool);
  621.         str_inf1 = [upper(Wave_Fam) ' wavelet'] ;
  622.         if size(tabNums,1)>1
  623.             str_inf1 = [str_inf1 's'] ;
  624.         end
  625.         set(pus_inf1,'String',str_inf1);
  626.         wvdtool('draw1d',win_loctool);
  627.     case 'close'
  628.     otherwise
  629.         errargt(mfilename,'Unknown Option','msg');
  630.         error('*');
  631. end
  632. %=============================================================================%
  633. % INTERNAL FUNCTIONS
  634. %=============================================================================%
  635. %-----------------------------------------------------------------------------%
  636. function axe = plotYval(xVal,yVal,axeProp,color,axeTitle)
  637. xlim  = [min(xVal) , max(xVal)];
  638. mini  = min(yVal);
  639. maxi  = max(yVal);
  640. dyVal = maxi-mini;
  641. if dyVal<sqrt(eps) , dyVal = sqrt(eps);end
  642. ylim = [mini maxi]+0.02*dyVal*[-1 1];
  643. axe  = axes(axeProp{:},'Xlim',xlim,'Ylim',ylim);
  644. line('Xdata',xVal,'Ydata',yVal,'Color',color,'Parent',axe);
  645. wtitle(axeTitle,'Parent',axe);
  646. %-----------------------------------------------------------------------------%
  647. %=============================================================================%