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

波变换

开发平台:

Matlab

  1. function out1 = dw1dstat(option,in2,in3,in4,in5,in6)
  2. %DW1DSTAT Discrete wavelet 1-D statistics.
  3. %   OUT1 = DW1DSTAT(OPTION,IN2,IN3,IN4,IN5,IN6)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 13-Jan-2001.
  6. %   Copyright 1995-2002 The MathWorks, Inc.
  7. %   $Revision: 1.21 $ $Date: 2002/06/17 12:19:13 $
  8. % Memory Blocks of stored values.
  9. %================================
  10. % MB1 (main Window).
  11. %-------------------
  12. n_param_anal   = 'DWAn1d_Par_Anal';
  13. ind_sig_name   = 1;
  14. ind_sig_size   = 2;
  15. ind_wav_name   = 3;
  16. ind_lev_anal   = 4;
  17. ind_axe_ref    = 5;
  18. ind_act_option = 6;
  19. ind_ssig_type  = 7;
  20. ind_thr_val    = 8;
  21. nb1_stored     = 8;
  22. % MB1 (local).
  23. %-------------
  24. n_misc_loc = ['MB1_' mfilename];
  25. ind_selbox     = 1;
  26. ind_curr_sig   = 2;
  27. ind_curr_color = 3;
  28. nbLOC_1_stored = 3;
  29. % Tag property of objects.
  30. %-------------------------
  31. tag_appdet_txt = 'Appdet_Txt';
  32. tag_appdet_val = 'Appdet_Val';
  33. tag_sel_cfs    = 'Sel_Cfs';
  34. tag_sel_rec    = 'Sel_Rec';
  35. tag_orig_sig   = 'Orig_sig';
  36. tag_synt_sig   = 'Synt_sig';
  37. tag_app_sig    = 'App_sig';
  38. tag_det_sig    = 'Det_sig';
  39. tag_bins_txt   = 'Bins_Txt';
  40. tag_bins_data  = 'Bins_Data';
  41. tag_levels     = 'Levels';
  42. tag_ax_signal  = 'Ax_Signal';
  43. tag_ax_hist    = 'Ax_Hist';
  44. tag_ax_cumhist = 'Ax_Cumhist';
  45. tag_show_stat  = 'Show_Stat';
  46. if ~isequal(option,'create') , win_stats = in2; end
  47. switch option
  48.     case 'create'
  49.         % Get Globals.
  50.         %-------------
  51.         [Def_Txt_Height,Def_Btn_Height,Pop_Min_Width, ...
  52.          X_Spacing,Y_Spacing,Def_EdiBkColor,Def_FraBkColor] = ...
  53.             mextglob('get',...
  54.                 'Def_Txt_Height','Def_Btn_Height','Pop_Min_Width', ...
  55.                 'X_Spacing','Y_Spacing','Def_EdiBkColor','Def_FraBkColor' ...
  56.                 );
  57.         % Calling figure.
  58.         %----------------
  59.         win_dw1dtool = in2;
  60.         str_win_dw1dtool = sprintf('%.0f',win_dw1dtool);
  61.         % Window initialization.
  62.         %----------------------
  63.         win_name = 'Wavelet 1-D  --  Statistics';
  64.         [win_stats,pos_win,win_units,str_numwin,...
  65.                 frame0,pos_frame0,Pos_Graphic_Area,pus_close] = ...
  66.                     wfigmngr('create',win_name,'','ExtFig_HistStat',mfilename,0);
  67.         out1 = win_stats;
  68. % Add Help for Tool.
  69. %------------------
  70. wfighelp('addHelpTool',win_stats,'Statistics','DW1D_STAT_GUI');
  71.         % Begin waiting.
  72.         %---------------
  73.         set(wfindobj('figure'),'Pointer','watch');
  74.         % Getting variables from dw1dtool figure memory block.
  75.         %-----------------------------------------------------
  76.         [Sig_Name,Wav_Name,Lev_Anal,Sig_Size,Axe_Ref] = ...
  77.                 wmemtool('rmb',win_dw1dtool,n_param_anal,  ...
  78.                         ind_sig_name,ind_wav_name,         ...
  79.                         ind_lev_anal,ind_sig_size,ind_axe_ref);
  80.         % General graphical parameters initialization.
  81.         %--------------------------------------------
  82.         dx = X_Spacing;  dx2 = 2*dx;
  83.         dy = Y_Spacing;  dy2 = 2*dy;
  84.         gra_width = Pos_Graphic_Area(3);
  85.         x_frame0  = pos_frame0(1);
  86.         cmd_width = pos_frame0(3);
  87.         h_frame0  = pos_frame0(4);
  88.         % Buttons width
  89.         push_width = (cmd_width-4*dx)/2;
  90.         pop_width  = Pop_Min_Width;
  91.         % Parameters initialization.
  92.         %---------------------------
  93.         default_bins = 30;
  94.         % Position property of objects.
  95.         %------------------------------
  96.         xlocINI    = pos_frame0([1 3]);
  97.         ybottomINI = pos_win(4)-3.5*Def_Btn_Height-dy2;
  98.         w_chk      = 7*push_width/4;
  99.         h_chk      = 3*Def_Btn_Height/2;
  100.         d_higth    = Def_Btn_Height;
  101.         d_txt      = Def_Btn_Height-Def_Txt_Height;
  102.         % For 640x480 resolution
  103.         %-----------------------
  104.         d_higth = depOfMachine(d_higth);
  105.         
  106.         x_left          = x_frame0+(cmd_width-w_chk)/2;
  107.         y_low           = ybottomINI-Def_Btn_Height-10*dy;
  108.         pos_orig_sig    = [x_left , y_low , w_chk , h_chk];
  109.         y_low           = y_low-Def_Btn_Height-d_higth;        
  110.         pos_synt_sig    = [x_left , y_low , w_chk , h_chk];
  111.         y_low           = y_low-Def_Btn_Height-d_higth;        
  112.         pos_app_sig     = [x_left , y_low , w_chk , h_chk];
  113.         y_low           = y_low-Def_Btn_Height-d_higth;        
  114.         pos_det_sig     = [x_left , y_low , w_chk , h_chk];
  115.         x_left          = x_frame0+(cmd_width-3*push_width/2)/2;
  116.         y_low           = pos_det_sig(2)-2*Def_Btn_Height;
  117.         pos_appdet_txt  = [x_left , y_low+d_txt/2 , 3*push_width/2 , Def_Txt_Height];
  118.         y_low           = y_low-Def_Btn_Height;
  119.         pos_appdet_val  = [x_left , y_low , 3*push_width/2 , Def_Btn_Height];
  120.         x_left          = x_frame0+(cmd_width-5*push_width/4)/2;
  121.         y_low           = pos_appdet_val(2)-2*Def_Btn_Height;
  122.         pos_sel_cfs     = [x_left , y_low , 5*push_width/4 , Def_Btn_Height];
  123.         y_low           = y_low-h_chk;
  124.         pos_sel_rec     = [x_left , y_low , 5*push_width/4 , Def_Btn_Height];
  125.         x_left          = x_frame0+(cmd_width-3*pop_width)/2;
  126.         y_low           = pos_sel_rec(2)-Def_Btn_Height-d_higth;
  127.         pos_bins_txt    = [x_left , y_low+d_txt/2 , 2*pop_width , Def_Txt_Height];
  128.         x_left          = x_left+2*pop_width+dx;
  129.         pos_bins_data   = [x_left , y_low , pop_width , Def_Btn_Height];
  130.         x_left          = x_frame0+(cmd_width-3*push_width/2)/2;
  131.         y_low           = pos_bins_data(2)-2*Def_Btn_Height-d_higth;
  132.         pos_show_stat   = [x_left , y_low , 3*push_width/2 , 2*Def_Btn_Height];
  133.         % String property of objects.
  134.         %----------------------------
  135.         ss_type = wmemtool('rmb',win_dw1dtool,n_param_anal,ind_ssig_type);
  136.         switch ss_type
  137.             case 'ss', str_ss = 'Synthesized signal';
  138.             case 'ds', str_ss = 'De-noised signal';
  139.             case 'cs', str_ss = 'Compressed signal';
  140.         end
  141.         str_synt_sig    = str_ss;
  142.         str_orig_sig    = 'Original signal';
  143.         str_app_sig     = 'Approximation';
  144.         str_det_sig     = 'Detail';
  145.         str_app_txt     = 'Approximation at';
  146.         str_det_txt     = 'Detail at';
  147.         str_sel_cfs     = 'Coefficients';
  148.         str_sel_rec     = 'Reconstructed';
  149.         str_bins_txt    = 'Number of bins';
  150.         str_bins_data   = sprintf('%.0f',default_bins);
  151.         str_show_stat   = 'Show statistics';
  152.         str_appdet_val  = [];
  153.         for i = 1:Lev_Anal
  154.  str_appdet_val = [str_appdet_val ; sprintf('Level %2.0f', i)];
  155.         end
  156.         % Command part construction of the window.
  157.         %-----------------------------------------
  158.         if ~isequal(get(0,'CurrentFigure'),win_stats) , figure(win_stats); end
  159.         utanapar('create_copy',win_stats, ...
  160.                  {'xloc',xlocINI,'bottom',ybottomINI},...
  161.                  {'n_s',{Sig_Name,Sig_Size},'wav',Wav_Name,'lev',Lev_Anal} ...
  162.                  );
  163.         commomProp = {'Parent',win_stats,'Unit',win_units};
  164.         comRadProp = {commomProp{:},'Style','Radiobutton','Enable','off'};
  165.         rad_orig_sig    = uicontrol(comRadProp{:},...
  166.                                     'Position',pos_orig_sig,...
  167.                                     'String',str_orig_sig,...
  168.                                     'Value',1,...
  169.                                     'Userdata',1,...
  170.                                     'Tag',tag_orig_sig...
  171.                                     );
  172.         rad_synt_sig    = uicontrol(comRadProp{:},...
  173.                                     'Position',pos_synt_sig,...
  174.                                     'String',str_synt_sig,...
  175.                                     'Tag',tag_synt_sig...
  176.                                     );
  177.         rad_app_sig     = uicontrol(comRadProp{:},...
  178.                                     'Position',pos_app_sig,...
  179.                                     'String',str_app_sig,...
  180.                                     'Tag',tag_app_sig...
  181.                                     );
  182.         rad_det_sig     = uicontrol(comRadProp{:},...
  183.                                     'Position',pos_det_sig,...
  184.                                     'String',str_det_sig,...
  185.                                     'Tag',tag_det_sig...
  186.                                     );
  187.         txt_appdet_txt  = uicontrol(commomProp{:},...
  188.                                     'Style','Text',...
  189.                                     'Position',pos_appdet_txt,...
  190.                                     'String',str_app_txt,...
  191.                                     'Visible','off',...
  192.                                     'Tag',tag_appdet_txt,...
  193.                                     'Backgroundcolor',Def_FraBkColor...
  194.                                     );
  195.         pop_appdet_val  = uicontrol(commomProp{:},...
  196.                                     'Style','Popup',...
  197.                                     'Position',pos_appdet_val,...
  198.                                     'String',str_appdet_val,...
  199.                                     'Visible','off',...
  200.                                     'Userdata',1,...
  201.                                     'Tag',tag_appdet_val...
  202.                                     );
  203.         rad_sel_cfs     = uicontrol(commomProp{:},...
  204.                                     'Style','Radiobutton',...
  205.                                     'Position',pos_sel_cfs,...
  206.                                     'String',str_sel_cfs,...
  207.                                     'Visible','off',...
  208.                                     'Tag',tag_sel_cfs,...
  209.                                     'Userdata',0,...
  210.                                     'Value',0);
  211.         rad_sel_rec     = uicontrol(commomProp{:},...
  212.                                     'Style','Radiobutton',...
  213.                                     'Unit',win_units,...
  214.                                     'Position',pos_sel_rec,...
  215.                                     'String',str_sel_rec,...
  216.                                     'Visible','off',...
  217.                                     'Tag',tag_sel_rec,...
  218.                                     'Userdata',1,...
  219.                                     'Value',1);
  220.         txt_bins_txt    = uicontrol(commomProp{:},...
  221.                                     'Style','text',...
  222.                                     'Position',pos_bins_txt,...
  223.                                     'String',str_bins_txt,...
  224.                                     'Backgroundcolor',Def_FraBkColor,...
  225.                                     'Visible','off',...
  226.                                     'Tag',tag_bins_txt...
  227.                                     );
  228.         edi_bins_data   = uicontrol(commomProp{:},...
  229.                                     'Style','Edit',...
  230.                                     'Position',pos_bins_data,...
  231.                                     'String',str_bins_data,...
  232.                                     'Backgroundcolor',Def_EdiBkColor,...
  233.                                     'Visible','off',...
  234.                                     'Tag',tag_bins_data...
  235.                                     );
  236.         pus_show_stat   = uicontrol(commomProp{:},...
  237.                                     'Style','Pushbutton',...
  238.                                     'Position',pos_show_stat,...
  239.                                     'String',xlate(str_show_stat),...
  240.                                     'Visible','off',...
  241.                                     'Userdata',[],...
  242.                                     'Tag',tag_show_stat...
  243.                                     );
  244.         coeff_vari_pos  = 2;
  245.         pos_bins_txt(2) = pos_det_sig(2)-coeff_vari_pos*2*pos_det_sig(4)/3;
  246.         pos_bins_data(2)= pos_bins_txt(2);
  247.         pos_show_stat(2)= pos_bins_data(2)-3*2*pos_det_sig(4)/3;
  248.         set(txt_bins_txt,'Position',pos_bins_txt,'Visible','on');
  249.         set(edi_bins_data,'Position',pos_bins_data,'Visible','on');
  250.         set(pus_show_stat,'Position',pos_show_stat,'Visible','on');
  251.         % Frame Stats. construction.
  252.         %---------------------------
  253.         [infos_hdls,h_frame1] = utstats('create',win_stats,   ...
  254.                                         'xloc',Pos_Graphic_Area([1,3]), ...
  255.                                         'bottom',dy2);
  256.         
  257.         % Sets of handles.
  258.         %-----------------
  259.         set1_hdls = [txt_appdet_txt;pop_appdet_val;rad_sel_cfs;rad_sel_rec];
  260.         set2_hdls = [txt_bins_txt;edi_bins_data;pus_show_stat];
  261.         % Selected box limits.
  262.         %---------------------
  263.         xlim_selbox = mngmbtn('getbox',win_dw1dtool); 
  264.         if ~isempty(xlim_selbox)
  265.             xlim_selbox = [min(xlim_selbox) max(xlim_selbox)];
  266.         else
  267.             xlim_selbox = get(Axe_Ref,'XLim');
  268.         end
  269.         xlim_selbox = round(xlim_selbox);
  270.         xlim1       = xlim_selbox(1);
  271.         xlim2       = xlim_selbox(2);
  272.         if xlim1<1,        xlim1 = 1;        end
  273.         if xlim2>Sig_Size, xlim2 = Sig_Size; end
  274.         if (xlim2<1) | (xlim1>Sig_Size), return; end
  275.         selbox = [xlim1 xlim2];
  276.         % Callbacks update.
  277.         %------------------
  278.         str_infos_hdls     = num2mstr(infos_hdls);
  279.         str_group_hdls     = num2mstr([set2_hdls;set1_hdls]);
  280.         str_set2_hdls      = num2mstr(set2_hdls);
  281.         str_rad_orig_sig   = num2mstr(rad_orig_sig);
  282.         str_rad_synt_sig   = num2mstr(rad_synt_sig);
  283.         str_rad_app_sig    = num2mstr(rad_app_sig);
  284.         str_rad_det_sig    = num2mstr(rad_det_sig);
  285.         str_pop_appdet_val = num2mstr(pop_appdet_val);
  286.         str_rad_sel_rec    = num2mstr(rad_sel_rec);
  287.         str_rad_sel_cfs    = num2mstr(rad_sel_cfs);
  288.         str_edi_bins_data  = num2mstr(edi_bins_data);
  289.         cba_orig_sig       = [mfilename '(''select'','  ...
  290.                                    str_numwin ','       ...
  291.                                    str_rad_orig_sig ',' ...
  292.                                    str_infos_hdls ','   ...
  293.                                    str_group_hdls ','   ...
  294.                                    str_set2_hdls        ...
  295.                                    ');'];
  296.         cba_synt_sig       = [mfilename '(''select'','  ...
  297.                                    str_numwin ','       ...
  298.                                    str_rad_synt_sig ',' ...
  299.                                    str_infos_hdls ','   ...
  300.                                    str_group_hdls ','   ...
  301.                                    str_set2_hdls        ...
  302.                                    ');'];
  303.         cba_app_sig        = [mfilename '(''select'',' ...
  304.                                    str_numwin ','      ...
  305.                                    str_rad_app_sig ',' ...
  306.                                    str_infos_hdls ','  ...
  307.                                    str_group_hdls ','  ...
  308.                                    str_group_hdls      ...
  309.                                    ');'];
  310.         cba_det_sig        = [mfilename '(''select'',' ...
  311.                                    str_numwin ','      ...
  312.                                    str_rad_det_sig ',' ...
  313.                                    str_infos_hdls ','  ...
  314.                                    str_group_hdls ','  ...
  315.                                    str_group_hdls      ...
  316.                                    ');'];
  317.         cba_pop_appdet_val = [mfilename '(''upd'','       ...
  318.                                    str_numwin ',''lvl'',' ...
  319.                                    str_infos_hdls ','     ...
  320.                                    str_pop_appdet_val     ...
  321.                                    ');'];
  322.         cba_sel_rec        = [mfilename '(''upd'','       ...
  323.                                    str_numwin ',''cfs'',' ...
  324.                                    str_infos_hdls ','     ...
  325.                                    str_rad_sel_rec        ...
  326.                                    ');'];
  327.         cba_sel_cfs        = [mfilename '(''upd'','       ...
  328.                                    str_numwin ',''cfs'',' ...
  329.                                    str_infos_hdls ','     ...
  330.                                    str_rad_sel_cfs        ...
  331.                                    ');'];
  332.         cba_bins_data      = [mfilename '(''update_bins'',' ...
  333.                                    str_numwin ','           ...
  334.                                    str_edi_bins_data        ...
  335.                                    ');'];
  336.         cba_show_stat      = [mfilename '(''draw'','    ...
  337.                                    str_numwin ','       ...
  338.                                    str_win_dw1dtool ',' ...
  339.                                    str_infos_hdls ');'];
  340.         set(rad_orig_sig,'Callback',cba_orig_sig);
  341.         set(rad_synt_sig,'Callback',cba_synt_sig);
  342.         set(rad_app_sig,'Callback',cba_app_sig);
  343.         set(rad_det_sig,'Callback',cba_det_sig);
  344.         set(pop_appdet_val,'Callback',cba_pop_appdet_val);
  345.         set(rad_sel_rec,'Callback',cba_sel_rec);
  346.         set(rad_sel_cfs,'Callback',cba_sel_cfs);
  347.         set(edi_bins_data,'Callback',cba_bins_data);
  348.         set(pus_show_stat,'Callback',cba_show_stat);
  349.         % Memory blocks update.
  350.         %----------------------
  351.         wmemtool('ini',win_stats,n_misc_loc,nbLOC_1_stored);
  352.         wmemtool('wmb',win_stats,n_misc_loc,ind_selbox,selbox);
  353.         % Axes construction.
  354.         %-------------------
  355.         xspace         = gra_width/10;
  356.         yspace         = pos_frame0(4)/10;
  357.         axe_height     = (pos_frame0(4)-Def_Btn_Height-h_frame1-4*dy)/2-yspace;
  358.         axe_width      = gra_width-2*xspace;
  359.         half_width     = axe_width/2-xspace/2;
  360.         pos_ax_signal  = [xspace h_frame1+2*dy2+axe_height+4*yspace/3 ...
  361.                                 axe_width axe_height];
  362.         pos_ax_hist    = [xspace h_frame1+2*dy2+yspace/3 ...
  363.                                 half_width axe_height];
  364.         pos_ax_cumhist = [2*xspace+half_width h_frame1+2*dy2+yspace/3 ...
  365.                                 half_width axe_height];
  366.         commonProp = {...
  367.            'Parent',win_stats,...
  368.            'Units',win_units,...
  369.            'Visible','Off',...
  370.            'box','on',...
  371.            'NextPlot','Replace',...
  372.            'Drawmode','fast'...
  373.            };
  374.         axe_signal  = axes(commonProp{:},...
  375.                            'Position',pos_ax_signal,'Tag',tag_ax_signal);
  376.         axe_hist    = axes(commonProp{:},...
  377.                            'Position',pos_ax_hist,'Tag',tag_ax_hist);
  378.         axe_cumhist = axes(commonProp{:},...
  379.                            'Position',pos_ax_cumhist,'Tag',tag_ax_cumhist);
  380.         drawnow
  381.         % Displaying the window title.
  382.         %-----------------------------
  383.         str_nb_val   = [' (' sprintf('%.0f',Sig_Size) ' values)'];
  384.         str_wintitle = [Sig_Name,str_nb_val,' analyzed at level ',...
  385.                         sprintf('%.0f',Lev_Anal),' with ',Wav_Name];
  386.         str_wintitle = [str_wintitle '.  Components :   ' ,...
  387.                         sprintf('%.0f',selbox(1)) ' --> ' ...
  388.                         sprintf('%.0f',selbox(2))];
  389.         wfigtitl('string',win_stats,str_wintitle,'off');
  390.         % Setting units to normalized.
  391.         %-----------------------------
  392.         wfigmngr('normalize',win_stats);
  393. % Initialization with signal statistics (31/08/2000).
  394. %----------------------------------------------------
  395.         dw1dstat('draw',win_stats,win_dw1dtool,infos_hdls);
  396.         % End waiting.
  397.         %-------------
  398. set(wfindobj('figure'),'Pointer','arrow');
  399.         set([rad_orig_sig rad_synt_sig rad_app_sig rad_det_sig],'Enable','on');
  400.     case 'select'
  401.         %***********************************************%
  402.         %** OPTION = 'select' - SIGNAL TYPE SELECTION **%
  403.         %***********************************************%
  404.         sel_rad_btn = in3;
  405.         infos_hdls  = in4;
  406.         group_hdls  = in5;
  407.         curr_hdls   = in6;
  408.         % Set to the current selection.
  409.         %------------------------------
  410.         rad_handles  = findobj(win_stats,'Style','radiobutton');
  411.         rad_orig_sig = findobj(rad_handles,'Tag',tag_orig_sig);
  412.         rad_synt_sig = findobj(rad_handles,'Tag',tag_synt_sig);
  413.         rad_app_sig  = findobj(rad_handles,'Tag',tag_app_sig);
  414.         rad_det_sig  = findobj(rad_handles,'Tag',tag_det_sig);
  415.         rad_opt      = [rad_orig_sig rad_synt_sig rad_app_sig rad_det_sig];
  416.         old_rad      = findobj(rad_opt,'Userdata',1);
  417.         set(rad_opt,'Value',0,'Userdata',[]);
  418.         set(sel_rad_btn,'Value',1,'Userdata',1)
  419.         if old_rad==sel_rad_btn , return; end
  420.         % Reset all.
  421.         %-----------
  422.         axe_handles    = findobj(win_stats,'Type','axes');
  423.         axe_ax_signal  = findobj(axe_handles,'flat','Tag',tag_ax_signal);
  424.         axe_ax_hist    = findobj(axe_handles,'flat','Tag',tag_ax_hist);
  425.         axe_ax_cumhist = findobj(axe_handles,'flat','Tag',tag_ax_cumhist);
  426.         set([infos_hdls',group_hdls'],'Visible','off');
  427.         set(findobj([axe_ax_signal,axe_ax_hist,axe_ax_cumhist]),...
  428.                 'visible','off');
  429.         drawnow
  430.         % Redraw the command part depending on the current selection.
  431.         %------------------------------------------------------------
  432.         pos_det_sig    = get(rad_det_sig,'Position');
  433.         pos_bins_txt   = get(curr_hdls(1),'Position');
  434.         pos_bins_data  = get(curr_hdls(2),'Position');
  435.         pos_show_stat  = get(curr_hdls(3),'Position');
  436.         coeff_vari_pos = 9;
  437.         if sel_rad_btn==rad_app_sig
  438.             set(curr_hdls(4),'String',xlate('Approximation at'))
  439.         elseif sel_rad_btn==rad_det_sig
  440.             set(curr_hdls(4),'String',xlate('Detail at'))
  441.         elseif sel_rad_btn==rad_orig_sig | sel_rad_btn==rad_synt_sig
  442.             coeff_vari_pos = 2;
  443.         end
  444.         pos_bins_txt(2) = pos_det_sig(2)-coeff_vari_pos*2*pos_det_sig(4)/3;
  445.         pos_bins_data(2)= pos_bins_txt(2);
  446.         pos_show_stat(2)= pos_bins_data(2)-3*2*pos_det_sig(4)/3;
  447.         set(curr_hdls(1),'Position',pos_bins_txt);
  448.         set(curr_hdls(2),'Position',pos_bins_data);
  449.         set(curr_hdls(3),'Position',pos_show_stat);
  450.         set(curr_hdls,'Visible','On');
  451.     case 'upd'
  452.         %***************************************%
  453.         %** OPTION = 'upd' - UPDATE :         **%
  454.         %**     COEFFICIENTS TYPE SELECTION   **%
  455.         %**     LEVEL NUMBER SELECTION        **%
  456.         %***************************************%
  457.         opt        = in3;
  458.         infos_hdls = in4;
  459.         % Set to the current selection.
  460.         %------------------------------
  461.         if opt=='cfs'
  462.             sel_rad_btn = in5;
  463.             rad_handles = findobj(win_stats,'Style','radiobutton');
  464.             rad_sel_rec = findobj(rad_handles,'Tag',tag_sel_rec);
  465.             rad_sel_cfs = findobj(rad_handles,'Tag',tag_sel_cfs);
  466.             rad_opt     = [rad_sel_rec rad_sel_cfs];
  467.             old_rad     = findobj(rad_opt,'Userdata',1);
  468.             set(rad_opt,'Value',0,'Userdata',0);
  469.             set(sel_rad_btn,'Value',1,'Userdata',1)
  470.             if old_rad==sel_rad_btn , return; end
  471.         elseif opt=='lvl'
  472.             pop_level = in5;
  473.             val_pop = get(pop_level,'value');
  474.             usr_pop = get(pop_level,'userdata');
  475.             if usr_pop==val_pop , return; end
  476.             set(pop_level,'userdata',val_pop);
  477.         end
  478.         % Reset all.
  479.         %-----------
  480.         axe_handles    = findobj(win_stats,'Type','axes');
  481.         axe_ax_signal  = findobj(axe_handles,'flat','Tag',tag_ax_signal);
  482.         axe_ax_hist    = findobj(axe_handles,'flat','Tag',tag_ax_hist);
  483.         axe_ax_cumhist = findobj(axe_handles,'flat','Tag',tag_ax_cumhist);
  484.         set(infos_hdls,'Visible','off');
  485.         set(findobj([axe_ax_signal,axe_ax_hist,axe_ax_cumhist]),...
  486.                 'visible','off');
  487.         drawnow
  488.     case 'draw'
  489.         %*********************************%
  490.         %** OPTION = 'draw' - DRAW AXES **%
  491.         %*********************************%
  492.         win_dw1dtool = in3;
  493.         infos_hdls   = in4;
  494.         % Handles of tagged objects.
  495.         %---------------------------
  496.         children       = get(win_stats,'Children');
  497.         uic_handles    = findobj(children,'flat','type','uicontrol');
  498.         pus_show_stat  = findobj(uic_handles,...
  499.                                        'Style','pushbutton',...
  500.                                        'Tag',tag_show_stat...
  501.                                        );
  502.         rad_handles    = findobj(uic_handles,'Style','radiobutton');
  503.         edi_handles    = findobj(uic_handles,'Style','edit');
  504.         txt_handles    = findobj(uic_handles,'Style','text');
  505.         pop_handles    = findobj(uic_handles,'Style','popupmenu');
  506.         rad_sel_cfs    = findobj(rad_handles,'Tag',tag_sel_cfs);
  507.         rad_orig_sig   = findobj(rad_handles,'Tag',tag_orig_sig);
  508.         rad_synt_sig   = findobj(rad_handles,'Tag',tag_synt_sig);
  509.         rad_app_sig    = findobj(rad_handles,'Tag',tag_app_sig);
  510.         rad_det_sig    = findobj(rad_handles,'Tag',tag_det_sig);
  511.         edi_bins_data  = findobj(edi_handles,'Tag',tag_bins_data);
  512.         pop_appdet_val = findobj(pop_handles,'Tag',tag_appdet_val);
  513.         % Handles of tagged objects continuing.
  514.         %-------------------------------------
  515.         axe_handles    = findobj(children,'flat','type','axes');
  516.         axe_ax_signal  = findobj(axe_handles,'flat','Tag',tag_ax_signal);
  517.         axe_ax_hist    = findobj(axe_handles,'flat','Tag',tag_ax_hist);
  518.         axe_ax_cumhist = findobj(axe_handles,'flat','Tag',tag_ax_cumhist);
  519.         % Main parameters selection before drawing.
  520.         %------------------------------------------
  521.         sel_cfs  = (get(rad_sel_cfs,'Value')~=0);
  522.         orig_sig = (get(rad_orig_sig,'Value')~=0);
  523.         synt_sig = (get(rad_synt_sig,'Value')~=0);
  524.         app_sig  = (get(rad_app_sig,'Value')~=0);
  525.         det_sig  = (get(rad_det_sig,'Value')~=0);
  526.         % Check the bins number.
  527.         %-----------------------
  528.         default_bins = 30;
  529.         old_params   = get(pus_show_stat,'Userdata');
  530.         if ~isempty(old_params) , default_bins = old_params(1); end
  531.         nb_bins = wstr2num(get(edi_bins_data,'String'));
  532.         if isempty(nb_bins) | (nb_bins<2)
  533.             nb_bins = default_bins;   
  534.             set(edi_bins_data,'String',sprintf('%.0f',default_bins))
  535.         end
  536.         level = get(pop_appdet_val,'value');
  537.         new_params = [ nb_bins sel_cfs orig_sig synt_sig ...
  538.                        app_sig det_sig level             ...
  539.                        ];
  540.         if ~isempty(old_params) & (new_params==old_params)
  541.             vis = get(axe_ax_hist,'Visible');
  542.             if vis(1:2)=='on', return, end
  543.         end
  544.         % Deseable new selection.
  545.         %-------------------------
  546.         pop_handles = cbanapar('no_pop',win_stats,pop_handles);
  547.         set([pop_handles;rad_handles;edi_bins_data],'Enable','off');
  548.         % Updating parameters.
  549.         %--------------------- 
  550.         set(pus_show_stat,'Userdata',new_params);
  551.         % Show the status line.
  552.         %----------------------
  553.         wfigtitl('vis',win_stats,'on');
  554.         % Cleaning the graphical part.
  555.         %-----------------------------
  556.         set(infos_hdls,'Visible','off');
  557.         set(findobj([axe_ax_signal,axe_ax_hist,axe_ax_cumhist]),...
  558.                 'visible','off');
  559.         drawnow
  560.         % Waiting message.
  561.         %-----------------
  562.         wwaiting('msg',win_stats,'Wait ... computing');
  563.         % Getting memory blocks.
  564.         %-----------------------
  565.         [Sig_Name,Wav_Name,Lev_Anal] = ...
  566.                         wmemtool('rmb',win_dw1dtool,n_param_anal, ...
  567.                                        ind_sig_name,ind_wav_name,ind_lev_anal);
  568.         selbox_orig = wmemtool('rmb',win_stats,n_misc_loc,ind_selbox);
  569.         % Definition of the complete selection box.
  570.         %-----------------------------------------
  571.         selbox_orig     = selbox_orig(1):selbox_orig(2);
  572.         % Current signal construction.
  573.         %-----------------------------
  574.         if orig_sig
  575.             curr_sig   = dw1dfile('sig',win_dw1dtool);
  576.             curr_color = wtbutils('colors','sig');
  577.             str_title  = 'Original signal';
  578.         elseif synt_sig
  579.             curr_sig   = dw1dfile('ssig',win_dw1dtool);
  580.             curr_color = wtbutils('colors','ssig');
  581.             ss_type = wmemtool('rmb',win_dw1dtool,n_param_anal,...
  582.                                                     ind_ssig_type);
  583.             switch ss_type
  584.                 case 'ss', str_ss = 'Synthesized signal';
  585.                 case 'ds', str_ss = 'De_noised signal';
  586.                 case 'cs', str_ss = 'Compressed signal';
  587.             end
  588.             str_title = str_ss;
  589.         elseif app_sig
  590.             if sel_cfs
  591.                 [curr_sig,set_ylim,ymin,ymax] = ...
  592.                         dw1dfile('app_cfs',win_dw1dtool,level,1);
  593.                 str_title= sprintf('Coefficients of approximation at level ');
  594.             else
  595.                 [curr_sig,set_ylim,ymin,ymax] = ...
  596.                         dw1dfile('app',win_dw1dtool,level,1);
  597.                 str_title= sprintf('Reconstructed approximation at level ');
  598.             end
  599.             col_app    = wtbutils('colors','app',Lev_Anal);
  600.             curr_color = col_app(level,:);
  601.             str_title  = [str_title, sprintf('%.0f',level)];
  602.         elseif det_sig
  603.             if sel_cfs
  604.                 [curr_sig,set_ylim,ymin,ymax] = ...
  605.                         dw1dfile('det_cfs',win_dw1dtool,level,1);
  606.                 str_title= sprintf('Coefficients of detail at level ');
  607.             else
  608.                 [curr_sig,set_ylim,ymin,ymax] = ...
  609.                         dw1dfile('det',win_dw1dtool,level,1);
  610.                 str_title= sprintf('Reconstructed detail at level ');
  611.             end
  612.             col_det    = wtbutils('colors','det',Lev_Anal);
  613.             curr_color = col_det(level,:);
  614.             str_title  = [str_title, sprintf('%.0f',level)];
  615.         end
  616.         selbox  = selbox_orig;
  617.         if sel_cfs & ~orig_sig & ~synt_sig
  618.             min_box = ceil(min(selbox)/2^level);
  619.             max_box = ceil(max(selbox)/2^level);
  620.             selbox  = min_box:max_box;
  621.         end
  622.         if length(selbox)<=2
  623.             wwarndlg([' Not enough coefficients remaining at level ' ...
  624.                       sprintf('%.0f',level)],...
  625.                       'Wavelet 1-D -- Statistics','block');
  626.             set([pop_handles;rad_handles;edi_bins_data],'Enable','on');
  627.             wwaiting('off',win_stats);
  628.             return;
  629.         else
  630.             curr_sig = curr_sig(selbox);
  631.         end
  632.         % Displaying the signal.
  633.         %-----------------------
  634.         xlim = [min(selbox)    max(selbox)];
  635.         ylim = [min(curr_sig)  max(curr_sig)];
  636.         if xlim(1)==xlim(2) , xlim = xlim+[-0.01 0.01]; end
  637.         if ylim(1)==ylim(2) , ylim = ylim+[-0.01 0.01]; end
  638.         if (app_sig | det_sig) & set_ylim
  639.             if ylim(1)<ymin , ylim(1) = ymin; end
  640.             if ylim(2)>ymax , ylim(2) = ymax; end
  641.         end
  642.         axes(axe_ax_signal);
  643.         plot(selbox,curr_sig,'Color',curr_color,'Parent',axe_ax_signal);
  644.         set(axe_ax_signal,'Visible','on','Xlim',xlim,'Ylim',ylim,...
  645.                 'Tag',tag_ax_signal);
  646.         wtitle(str_title,'Parent',axe_ax_signal);
  647.         % Displaying histogram.
  648.         %----------------------
  649.         his       = wgethist(curr_sig,nb_bins);
  650.         [xx,imod] = max(his(2,:));
  651.         mode_val  = (his(1,imod)+his(1,imod+1))/2;
  652.         his(2,:)  = his(2,:)/length(curr_sig);
  653.         axes(axe_ax_hist);
  654.         wplothis(axe_ax_hist,his,curr_color);
  655.         wtitle('Histogram','Parent',axe_ax_hist);
  656.         % Displaying cumulated histogram.
  657.         %--------------------------------
  658.         for i=6:4:length(his(2,:));
  659.             his(2,i)   = his(2,i)+his(2,i-4);
  660.             his(2,i+1) = his(2,i);
  661.         end
  662.         axes(axe_ax_cumhist);
  663.         wplothis(axe_ax_cumhist,[his(1,:);his(2,:)],curr_color);
  664.         wtitle('Cumulative histogram','Parent',axe_ax_cumhist);
  665.         % Displaying statistics.
  666.         %-----------------------
  667.         mean_val  = mean(curr_sig);
  668.         max_val   = max(curr_sig);
  669.         min_val   = min(curr_sig);
  670.         range_val = max_val-min_val;
  671.         std_val   = std(curr_sig);
  672.         med_val   = median(curr_sig);
  673.         utstats('display',win_stats, ...
  674.             [mean_val; med_val ; mode_val;  ...
  675.              max_val ; min_val ; range_val; ...
  676.              std_val ; median(abs(curr_sig-med_val)); ...
  677.              mean(abs(curr_sig-mean_val))]);
  678.         % Memory blocks update.
  679.         %----------------------
  680.         wmemtool('wmb',win_stats,n_misc_loc,...
  681.                        ind_curr_sig,curr_sig,ind_curr_color,curr_color);
  682.         % End waiting.
  683.         %-------------
  684.         wwaiting('off',win_stats);
  685.         % Setting infos visible.
  686.         %-----------------------
  687.         set(infos_hdls,'Visible','on');
  688.         % Enable new selection.
  689.         %----------------------
  690.         set([pop_handles;rad_handles;edi_bins_data],'Enable','on');
  691.     case 'update_bins'
  692.         %**************************************************************%
  693.         %** OPTION = 'update_bins' - UPDATE HISTOGRAMS WITH NEW BINS **%
  694.         %**************************************************************%
  695.         edi_bins_data = in3;
  696.         % Handles of tagged objects.
  697.         %---------------------------
  698.         pus_show_stat  = findobj(win_stats,...
  699.                                    'Style','pushbutton',...
  700.                                    'Tag',tag_show_stat...
  701.                                    );
  702.         axe_handles    = findobj(win_stats,'Type','axes');
  703.         axe_ax_hist    = findobj(axe_handles,'flat','Tag',tag_ax_hist);
  704.         axe_ax_cumhist = findobj(axe_handles,'flat','Tag',tag_ax_cumhist);
  705.         % Return if no current display.
  706.         %------------------------------
  707.         vis = get(axe_ax_hist,'Visible');
  708.         if vis(1:2)=='of', return, end
  709.         % Check the bins number.
  710.         %-----------------------
  711.         default_bins    = 30;
  712.         old_params      = get(pus_show_stat,'Userdata');
  713.         if ~isempty(old_params)
  714.             default_bins = old_params(1);
  715.         end
  716.         nb_bins = wstr2num(get(edi_bins_data,'String'));
  717.         if isempty(nb_bins) | (nb_bins<2)
  718.             nb_bins = default_bins;   
  719.             set(edi_bins_data,'String',sprintf('%.0f',default_bins))
  720.         end
  721.         if default_bins==nb_bins , return; end
  722.         % Getting memory blocks.
  723.         %-----------------------
  724.         [curr_sig,curr_color] = wmemtool('rmb',win_stats,n_misc_loc,...
  725.                                                ind_curr_sig,ind_curr_color);
  726.         % Updating histograms.
  727.         %---------------------
  728.         if ~isempty(curr_sig)
  729.             old_params(1) = nb_bins;
  730.             set(pus_show_stat,'Userdata',old_params);
  731.             his      = wgethist(curr_sig,nb_bins);
  732.             his(2,:) = his(2,:)/length(curr_sig);
  733.             wplothis(axe_ax_hist,his,curr_color);
  734.             wtitle('Histogram','Parent',axe_ax_hist);
  735.             for i=6:4:length(his(2,:));
  736.                 his(2,i)   = his(2,i)+his(2,i-4);
  737.                 his(2,i+1) = his(2,i);
  738.             end
  739.             wplothis(axe_ax_cumhist,[his(1,:);his(2,:)],curr_color);
  740.             wtitle('Cumulative histogram','Parent',axe_ax_cumhist);
  741.         end
  742.     case 'demo'
  743.         %****************************************%
  744.         %** OPTION = 'demo' -  DEMOS or TESTS  **%
  745.         %****************************************%
  746.         pus_show_stat = findobj(win_stats,...
  747.                                 'Style','pushbutton',...
  748.                                 'Tag',tag_show_stat...
  749.                                 );
  750.         eval(get(pus_show_stat,'Callback'));
  751.     case 'close'
  752.     otherwise
  753.         errargt(mfilename,'Unknown Option','msg');
  754.         error('*');
  755. end
  756. %-------------------------------------------------
  757. function varargout = depOfMachine(varargin)
  758. d_higth = varargin{1};
  759. scrSize = get(0,'ScreenSize');
  760. if scrSize(4)<600 , d_higth = d_higth/2; end
  761. varargout = {d_higth};
  762. %-------------------------------------------------