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

波变换

开发平台:

Matlab

  1. function out1 = dw2dhist(option,in2,in3,in4,in5,in6,in7)
  2. %DW2DHIST Discrete wavelet 2-D histograms.
  3. %   OUT1 = DW2DHIST(OPTION,IN2,IN3,IN4,IN5,IN6,IN7)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 12-Dec-2000.
  6. %   Copyright 1995-2002 The MathWorks, Inc.
  7. %   $Revision: 1.21 $
  8. % Memory Blocks of stored values.
  9. %================================
  10. % MB1.
  11. %-----
  12. n_param_anal   = 'DWAn2d_Par_Anal';
  13. ind_img_name   = 1;
  14. ind_wav_name   = 2;
  15. ind_lev_anal   = 3;
  16. ind_img_t_name = 4;
  17. ind_img_size   = 5;
  18. ind_nbcolors   = 6;
  19. ind_act_option = 7;
  20. ind_simg_type  = 8;
  21. ind_thr_val    = 9;
  22. nb1_stored     = 9;
  23. % MB2.1 & MB2.2
  24. %--------------
  25. n_coefs = 'MemCoefs';
  26. n_sizes = 'MemSizes';
  27. % MB3.
  28. %-----
  29. n_miscella      = 'DWAn2d_Miscella';
  30. ind_graph_area  =  1;
  31. ind_pos_axebig  =  2;
  32. ind_pos_axeini  =  3;
  33. ind_pos_axevis  =  4;
  34. ind_pos_axedec  =  5;
  35. ind_pos_axesyn  =  6;
  36. ind_pos_axesel  =  7;
  37. ind_view_status =  8;
  38. ind_save_status =  9;
  39. ind_sel_funct   = 10;
  40. nb3_stored      = 10;
  41. % Tag property of objects.
  42. %-------------------------
  43. tag_cmd_frame   = 'Cmd_Frame';
  44. tag_orig_sig    = 'Orig_sig';
  45. tag_synt_sig    = 'Synt_sig';
  46. tag_app_sig     = 'App_sig';
  47. tag_det_sig     = 'Det_sig';
  48. tag_app_txt     = 'App_Txt';
  49. tag_app_all     = 'App_All';
  50. tag_app_none    = 'App_None';
  51. tag_det_txt     = 'Det_Txt';
  52. tag_detdir_val  = 'Detdir_Val';
  53. tag_det_all     = 'Det_All';
  54. tag_det_none    = 'Det_None';
  55. tag_bins_txt    = 'Bins_Txt';
  56. tag_bins_data   = 'Bins_Data';
  57. tag_show_hist   = 'Show_Hist';
  58. tag_status_line = 'Status_Line';
  59. tag_fra_sep     = 'Frame_Separ';
  60. if ~isequal(option,'create') , win_dw2dhist = in2; end
  61. switch option
  62.     case 'create'
  63.         % Get Globals.
  64.         %-------------
  65.         [Def_Txt_Height,Def_Btn_Height,Def_Btn_Width, ...
  66.          Pop_Min_Width,X_Spacing,Y_Spacing,           ...
  67.          Def_EdiBkColor,Def_FraBkColor] = mextglob('get',...
  68.                 'Def_Txt_Height','Def_Btn_Height','Def_Btn_Width', ...
  69.                 'Pop_Min_Width','X_Spacing','Y_Spacing',           ...
  70.                 'Def_EdiBkColor','Def_FraBkColor');
  71.         % Calling figure.
  72.         %----------------
  73.         win_dw2dtool = in2;
  74.         str_win_dw2dtool = sprintf('%.0f',win_dw2dtool);
  75.         % Window initialization.
  76.         %----------------------
  77.         win_name = 'Wavelet 2-D  --  Histograms';
  78.         [win_dw2dhist,pos_win,win_units,str_numwin,...
  79.              frame0,pos_frame0,Pos_Graphic_Area,pus_close] = ...
  80.                  wfigmngr('create',win_name,'','ExtFig_HistStat',mfilename,0);
  81.         out1 = win_dw2dhist;
  82.         % Begin waiting.
  83.         %---------------
  84.         set(wfindobj('figure'),'Pointer','watch');
  85.         % Getting globals from dw2dtool figure memory block.
  86.         %---------------------------------------------------
  87.         [Img_Name,Img_Size,NB_ColorsInPal,Wav_Name,Lev_Anal] = ...
  88.         wmemtool('rmb',win_dw2dtool,n_param_anal, ...
  89.                        ind_img_name, ...
  90.                        ind_img_size, ...
  91.                        ind_nbcolors, ...
  92.                        ind_wav_name, ...
  93.                        ind_lev_anal  ...
  94.                        );
  95.         [Wav_Fam,Wav_Num] = wavemngr('fam_num',Wav_Name);
  96.         % General parameters initialization.
  97.         %-----------------------------------
  98.         dx = X_Spacing;  dx2 = 2*dx;
  99.         dy = Y_Spacing;  dy2 = 2*dy;
  100.         d_txt = (Def_Btn_Height-Def_Txt_Height);
  101.         x_frame0  = pos_frame0(1);
  102.         cmd_width = pos_frame0(3);
  103.         push_width = (cmd_width-4*dx)/2;
  104.         txt_width  = Def_Btn_Width;
  105.         pop_width  = Pop_Min_Width;
  106.         nb_inline   = 3;
  107.         default_bins = 50;
  108.         % Position property of objects.
  109.         %------------------------------
  110.         [chk_heigth,dy1_chk,dy_chk] = depOfMachine(Def_Btn_Height);
  111.         deltay  = min(dy2,dy1_chk);
  112.         xlocINI        = [x_frame0 cmd_width];
  113.         ybottomINI     = pos_win(4)-3.5*Def_Btn_Height-dy2;
  114.         y_low          = ybottomINI-2*Def_Btn_Height;
  115.         wx             = 7*push_width/4;
  116.         px             = x_frame0+(cmd_width-7*push_width/4)/2;
  117.         pos_orig_sig   = [px , y_low  , wx , chk_heigth];
  118.         y_low          = y_low-chk_heigth-dy1_chk;
  119.         pos_synt_sig   = [px , y_low  , wx , chk_heigth];
  120.         y_low          = y_low-chk_heigth-dy1_chk;
  121.         pos_app_sig    = [px , y_low  , wx , chk_heigth];
  122.         y_low          = y_low-chk_heigth-dy1_chk;
  123.         pos_det_sig    = [px , y_low  , wx , chk_heigth];
  124.         wx             = 3*push_width/2;
  125.         px             = x_frame0+(cmd_width-wx)/2;
  126.         y_low          = y_low-3*Def_Btn_Height/2;
  127.         pos_app_txt    = [px, y_low, wx, Def_Btn_Height];
  128.         nb             = nb_inline+1;
  129.         x_left         = x_frame0+(cmd_width-nb*txt_width/2)/(nb+1);
  130.         y_low          = y_low-Def_Btn_Height-deltay;
  131.         pos_app_all    = [x_left, y_low, txt_width/2, Def_Btn_Height];
  132.         y_low          = y_low-3*Def_Btn_Height/2;
  133.         pos_app_none   = [x_left, y_low, txt_width/2, Def_Btn_Height];
  134.         y_low          = pos_app_txt(2)-4*Def_Btn_Height;
  135.         pos_det_txt    = [px, y_low, wx, Def_Btn_Height];
  136.         y_low          = pos_det_txt(2)-4*Def_Btn_Height;
  137.         pos_detdir_val = [px, y_low, wx, Def_Btn_Height];
  138.         y_low          = pos_detdir_val(2)-3*Def_Btn_Height/2;
  139.         pos_det_all    = [x_left, y_low, txt_width/2, Def_Btn_Height];
  140.         y_low          = y_low-3*Def_Btn_Height/2;
  141.         pos_det_none   = [x_left, y_low, txt_width/2, Def_Btn_Height];
  142.         px             = x_frame0+(cmd_width-3*pop_width)/2;
  143.         y_low          = pos_det_txt(2)-4*Def_Btn_Height;
  144.         pos_bins_txt   = [px, y_low+d_txt/2, 2*pop_width, Def_Txt_Height];
  145.         px             = pos_bins_txt(1)+pos_bins_txt(3)+dx;
  146.         pos_bins_data  = [px, y_low, pop_width, Def_Btn_Height];
  147.         px             = x_frame0+(cmd_width-3*push_width/2)/2;
  148.         y_low          = y_low-3*Def_Btn_Height;
  149.         pos_show_hist  = [px, y_low, 3*push_width/2, 2*Def_Btn_Height];
  150.         % String property of objects.
  151.         %----------------------------
  152.         s_i = wmemtool('rmb',win_dw2dtool,n_param_anal,ind_simg_type);
  153.         if      s_i=='ss', str_ss = 'Synthesized image';
  154.         elseif  s_i=='ds', str_ss = 'De_noised image';
  155.         elseif  s_i=='cs', str_ss = 'Compressed image';
  156.         end
  157.         str_synt_sig    = str_ss;
  158.         str_orig_sig    = 'Original image';
  159.         str_app_sig     = 'Approximations';
  160.         str_det_sig     = 'Details';
  161.         str_app_txt     = 'Approximation levels';
  162.         str_appdet_all  = 'All';
  163.         str_appdet_none = 'None';
  164.         str_det_txt     = 'Detail levels';
  165.         str_detdir_val  = [ 'Horizontal' ; 'Diagonal  ' ; 'Vertical  '];
  166.         str_bins_txt    = 'Number of bins';
  167.         str_bins_data   = sprintf('%.0f',default_bins);
  168.         str_show_hist   = 'Show histograms';
  169.         % Command part construction of the window.
  170.         %-----------------------------------------
  171.         utanapar('create_copy',win_dw2dhist, ...
  172.                  {'xloc',xlocINI,'bottom',ybottomINI},...
  173.                  {'n_s',{Img_Name,Img_Size},'wav',Wav_Name,'lev',Lev_Anal} ...
  174.                  );
  175.         chk_orig_sig = uicontrol('Parent',win_dw2dhist,...
  176.                                  'Style','Checkbox',...
  177.                                  'Unit',win_units,...
  178.                                  'Position',pos_orig_sig,...
  179.                                  'String',str_orig_sig,...
  180.                                  'Enable','off',...
  181.                                  'UserData',0,...
  182.                                  'Tag',tag_orig_sig...
  183.                                  );
  184.         chk_synt_sig = uicontrol('Parent',win_dw2dhist,...
  185.                                  'Style','Checkbox',...
  186.                                  'Unit',win_units,...
  187.                                  'Position',pos_synt_sig,...
  188.                                  'String',str_synt_sig,...
  189.                                  'Enable','off',...
  190.                                  'UserData',0,...
  191.                                  'Tag',tag_synt_sig...
  192.                                  );
  193.         chk_app_sig  = uicontrol('Parent',win_dw2dhist,...
  194.                                  'Style','Checkbox',...
  195.                                  'Unit',win_units,...
  196.                                  'Position',pos_app_sig,...
  197.                                  'String',str_app_sig,...
  198.                                  'Enable','off',...
  199.                                  'UserData',0,...
  200.                                  'Tag',tag_app_sig...
  201.                                  );
  202.         chk_det_sig  = uicontrol('Parent',win_dw2dhist,...
  203.                                  'Style','Checkbox',...
  204.                                  'Unit',win_units,...
  205.                                  'Position',pos_det_sig,...
  206.                                  'String',str_det_sig,...
  207.                                  'Enable','off',...
  208.                                  'UserData',0,...
  209.                                  'Tag',tag_det_sig...
  210.                                  );
  211.         % Approximations checkboxes construction.
  212.         txt_app_txt  = uicontrol('Parent',win_dw2dhist,...
  213.                                  'Style','Text',...
  214.                                  'Unit',win_units,...
  215.                                  'Position',pos_app_txt,...
  216.                                  'String',str_app_txt,...
  217.                                  'Backgroundcolor',Def_FraBkColor,...
  218.                                  'Visible','off',...
  219.                                  'Tag',tag_app_txt...
  220.                                  );
  221.         pus_app_all  = uicontrol('Parent',win_dw2dhist,...
  222.                                  'Style','PushButton',...
  223.                                  'Unit',win_units,...
  224.                                  'Position',pos_app_all,...
  225.                                  'String',xlate(str_appdet_all),...
  226.                                  'Visible','off',...
  227.                                  'Tag',tag_app_all...
  228.                                  );
  229.         pus_app_none = uicontrol('Parent',win_dw2dhist,...
  230.                                  'Style','PushButton',...
  231.                                  'Unit',win_units,...
  232.                                  'Position',pos_app_none,...
  233.                                  'String',xlate(str_appdet_none),...
  234.                                  'Visible','off',...
  235.                                  'Tag',tag_app_none...
  236.                                  );
  237.         wx          = (cmd_width-nb*txt_width/2)/(nb+1);
  238.         xbtchk0     = x_frame0+txt_width/2+2*wx;
  239.         ybtchk0     = pos_app_txt(2)-Def_Btn_Height-deltay;
  240.         xbtchk      = xbtchk0;
  241.         ybtchk      = ybtchk0;
  242.         Chk_App_Lst = zeros(Lev_Anal,1);
  243.         for i=1:Lev_Anal
  244.             pos_app_i = [xbtchk ybtchk txt_width/2 Def_Btn_Height];
  245.             str_app_i = sprintf('%.0f',i);
  246.             tag_app_i = ['App' sprintf('%.0f',i)];
  247.             chk_app_i = uicontrol('Parent',win_dw2dhist,...
  248.                                   'Style','Checkbox',...
  249.                                   'Unit',win_units,...
  250.                                   'Position',pos_app_i,...
  251.                                   'String',str_app_i,...
  252.                                   'Visible','off',...
  253.                                   'Tag',tag_app_i...
  254.                                   );
  255.             Chk_App_Lst(i) = chk_app_i;
  256.             if rem(i,nb_inline)==0
  257.                 xbtchk = xbtchk0;
  258.                 ybtchk = ybtchk-Def_Btn_Height-dy_chk;
  259.             else
  260.                 xbtchk = xbtchk+txt_width/2+wx;
  261.             end
  262.         end
  263.         % Details checkboxes construction.
  264.         txt_det_txt    = uicontrol('Parent',win_dw2dhist,...
  265.                                    'Style','Text',...
  266.                                    'Unit',win_units,...
  267.                                    'Position',pos_det_txt,...
  268.                                    'String',str_det_txt,...
  269.                                    'Backgroundcolor',Def_FraBkColor,...
  270.                                    'Visible','off',...
  271.                                    'Tag',tag_det_txt...
  272.                                    );
  273.         pop_detdir_val = uicontrol('Parent',win_dw2dhist,...
  274.                                    'Style','Popup',...
  275.                                    'Unit',win_units,...
  276.                                    'Position',pos_detdir_val,...
  277.                                    'String',str_detdir_val,...
  278.                                    'Visible','off',...
  279.                                    'Tag',tag_detdir_val...
  280.                                    );
  281.         pus_det_all    = uicontrol('Parent',win_dw2dhist,...
  282.                                    'Style','PushButton',...
  283.                                    'Unit',win_units,...
  284.                                    'Position',pos_det_all,...
  285.                                    'String',xlate(str_appdet_all),...
  286.                                    'Visible','off',...
  287.                                    'Tag',tag_det_all...
  288.                                    );
  289.         pus_det_none   = uicontrol('Parent',win_dw2dhist,...
  290.                                    'Style','PushButton',...
  291.                                    'Unit',win_units,...
  292.                                    'Position',pos_det_none,...
  293.                                    'String',xlate(str_appdet_none),...
  294.                                    'Visible','off',...
  295.                                    'Tag',tag_det_none...
  296.                                    );
  297.         ybtchk0     = pos_det_txt(2)-Def_Btn_Height-dy_chk;
  298.         xbtchk      = xbtchk0;
  299.         ybtchk      = ybtchk0;
  300.         Chk_Det_Lst = zeros(Lev_Anal,1);
  301.         for i=1:Lev_Anal
  302.             pos_det_i = [xbtchk ybtchk txt_width/2 Def_Btn_Height];
  303.             str_det_i = sprintf('%.0f',i);
  304.             tag_det_i = ['Det' sprintf('%.0f',i)];
  305.             chk_det_i = uicontrol('Parent',win_dw2dhist,...
  306.                                   'Style','Checkbox',...
  307.                                   'Unit',win_units,...
  308.                                   'Position',pos_det_i,...
  309.                                   'String',str_det_i,...
  310.                                   'Visible','off',...
  311.                                   'Tag',tag_det_i...
  312.                                   );
  313.             Chk_Det_Lst(i) = chk_det_i;
  314.             if rem(i,nb_inline)==0
  315.                 xbtchk = xbtchk0;
  316.                 ybtchk = ybtchk-Def_Btn_Height-dy_chk;
  317.             else
  318.                 xbtchk = xbtchk+txt_width/2+wx;
  319.             end
  320.         end
  321.         txt_bins_txt  = uicontrol('Parent',win_dw2dhist,...
  322.                                   'Style','Text',...
  323.                                   'Unit',win_units,...
  324.                                   'Position',pos_bins_txt,...
  325.                                   'String',str_bins_txt,...
  326.                                   'Backgroundcolor',Def_FraBkColor,...
  327.                                   'Visible','off',...
  328.                                   'Tag',tag_bins_txt...
  329.                                   );
  330.         edi_bins_data = uicontrol('Parent',win_dw2dhist,...
  331.                                   'Style','Edit',...
  332.                                   'Unit',win_units,...
  333.                                   'Position',pos_bins_data,...
  334.                                   'String',str_bins_data,...
  335.                                   'Backgroundcolor',Def_EdiBkColor,...
  336.                                   'Visible','off',...
  337.                                   'Tag',tag_bins_data...
  338.                                   );
  339.         pus_show_hist = uicontrol('Parent',win_dw2dhist,...
  340.                                   'Style','Pushbutton',...
  341.                                   'Unit',win_units,...
  342.                                   'Position',pos_show_hist,...
  343.                                   'String',xlate(str_show_hist),...
  344.                                   'Interruptible','On',...
  345.                                   'Visible','off',...
  346.                                   'Userdata',[],...
  347.                                   'Tag',tag_show_hist...
  348.                                   );
  349.         drawnow
  350.         % Sets of handles.
  351.         %-----------------
  352.         set1_hdls = [txt_app_txt
  353.                      pus_app_all
  354.                      pus_app_none
  355.                      Chk_App_Lst];
  356.         set2_hdls = [txt_det_txt
  357.                      pop_detdir_val
  358.                      pus_det_all
  359.                      pus_det_none
  360.                      Chk_Det_Lst];
  361.         set3_hdls = [txt_bins_txt
  362.                      edi_bins_data
  363.                      pus_show_hist
  364.                      pus_close];
  365.         % Selected box limits.
  366.         %---------------------
  367.         Axe_Ref = findobj(get(win_dw2dtool,'Children'),'flat', ...
  368.                            'type','axes','Tag','Axe_ImgIni');
  369.         [xlim_selbox ylim_selbox]= mngmbtn('getbox',win_dw2dtool); 
  370.         if ~isempty(xlim_selbox)
  371.             xlim_selbox = [min(xlim_selbox) max(xlim_selbox)];
  372.         else
  373.             xlim_selbox = get(Axe_Ref,'XLim');
  374.         end
  375.         if ~isempty(ylim_selbox)
  376.             ylim_selbox = [min(ylim_selbox) max(ylim_selbox)];
  377.         else
  378.             ylim_selbox = get(Axe_Ref,'YLim');
  379.         end
  380.         xlim_selbox = round(xlim_selbox);
  381.         ylim_selbox = round(ylim_selbox);
  382.         xlim1       = xlim_selbox(1);
  383.         xlim2       = xlim_selbox(2);
  384.         ylim1       = ylim_selbox(1);
  385.         ylim2       = ylim_selbox(2);
  386.         if  xlim1<1,                xlim1 = 1;           end
  387.         if  xlim2>Img_Size(1),      xlim2 = Img_Size(1); end
  388.         if  (xlim2<1) | (xlim1>Img_Size(1)), return,     end
  389.         if  ylim1<1,                ylim1 = 1;           end
  390.         if  ylim2>Img_Size(2),      ylim2 = Img_Size(2); end
  391.         if  (ylim2<1) | (ylim1>Img_Size(2)), return,     end
  392.         selbox = [xlim1 xlim2 ylim1 ylim2];
  393.         % Callbacks update.
  394.         %------------------
  395.         str_set1_hdls     = num2mstr(set1_hdls);
  396.         str_set2_hdls     = num2mstr(set2_hdls);
  397.         str_set3_hdls     = num2mstr(set3_hdls);
  398.         str_group_hdls    = num2mstr([set1_hdls;set2_hdls;set3_hdls]);
  399.         str_chk_orig_sig  = num2mstr(chk_orig_sig);
  400.         str_chk_synt_sig  = num2mstr(chk_synt_sig);
  401.         str_chk_app_sig   = num2mstr(chk_app_sig);
  402.         str_chk_det_sig   = num2mstr(chk_det_sig);
  403.         str_Chk_App_Lst   = num2mstr(Chk_App_Lst);
  404.         str_Chk_Det_Lst   = num2mstr(Chk_Det_Lst);
  405.         str_edi_bins_data = num2mstr(edi_bins_data);
  406.         str_selbox        = num2mstr(selbox);
  407.         tmp_txt           = [str_set1_hdls ',' ...
  408.                              str_set2_hdls ',' ...
  409.                              str_set3_hdls ',' ...
  410.                              str_group_hdls];
  411.         cba_orig_sig  = [mfilename '(''select'',' ...
  412.                               str_numwin ',' ...
  413.                               str_chk_orig_sig ',' ...
  414.                               tmp_txt ...
  415.                               ');'];
  416.         cba_synt_sig  = [mfilename '(''select'',' ...
  417.                               str_numwin ',' ...
  418.                               str_chk_synt_sig ',' ...
  419.                               tmp_txt ...
  420.                               ');'];
  421.         cba_app_sig   = [mfilename '(''select'',' ...
  422.                               str_numwin ',' ...
  423.                               str_chk_app_sig ',' ...
  424.                               tmp_txt ...
  425.                               ');'];
  426.         cba_det_sig   = [mfilename '(''select'',' ...
  427.                               str_numwin ',' ...
  428.                               str_chk_det_sig ',' ...
  429.                               tmp_txt ...
  430.                               ');'];
  431.         cba_bins_data = [mfilename '(''update_bins'',' ...
  432.                               str_numwin ',' ...
  433.                               str_edi_bins_data ...
  434.                               ');'];
  435.         cba_app_all   = ['set(' str_Chk_App_Lst ',''Value'',1);'];
  436.         cba_app_none  = ['set(' str_Chk_App_Lst ',''Value'',0);'];
  437.         cba_det_all   = ['set(' str_Chk_Det_Lst ',''Value'',1);'];
  438.         cba_det_none  = ['set(' str_Chk_Det_Lst ',''Value'',0);'];
  439.         cba_show_hist = ['dw2dhist(''draw'',' ...
  440.                               str_numwin ',' ...
  441.                               str_win_dw2dtool ',' ...
  442.                               str_selbox ',' ...
  443.                               str_Chk_App_Lst ',' ...
  444.                               str_Chk_Det_Lst ');'];
  445.         set(chk_orig_sig,'Callback',cba_orig_sig);
  446.         set(chk_synt_sig,'Callback',cba_synt_sig);
  447.         set(chk_app_sig,'Callback',cba_app_sig);
  448.         set(chk_det_sig,'Callback',cba_det_sig);
  449.         set(pus_app_all,'Callback',cba_app_all);
  450.         set(pus_app_none,'Callback',cba_app_none);
  451.         set(pus_det_all,'Callback',cba_det_all);
  452.         set(pus_det_none,'Callback',cba_det_none);
  453.         set(edi_bins_data,'Callback',cba_bins_data);
  454.         set(pus_show_hist,'Callback',cba_show_hist);
  455.         % Displaying the window title.
  456.         %-----------------------------
  457.         str_nb_val   = [' (' sprintf('%.0f',Img_Size(1)) ' x ' sprintf('%.0f',Img_Size(2)) ')'];
  458.         str_wintitle = [Img_Name,str_nb_val,' analyzed at level ',...
  459.                         sprintf('%.0f',Lev_Anal),' with ',Wav_Name];
  460.         str_wintitle = [str_wintitle '  --->  X = ' ,...
  461.                         sprintf('%.0f',selbox(1)) ' : ' ...
  462.                         sprintf('%.0f',selbox(2)) '    Y = ' ...
  463.                         sprintf('%.0f',selbox(3)) ' : ' ...
  464.                         sprintf('%.0f',selbox(4))];
  465.         wfigtitl('string',win_dw2dhist,str_wintitle,'off');
  466.         % Setting units to normalized.
  467.         %-----------------------------
  468.         wfigmngr('normalize',win_dw2dhist);
  469. % Initialization with signal histogram (31/08/2000).
  470. %---------------------------------------------------
  471. set(chk_orig_sig,'Value',1);
  472. group_hdls = [set1_hdls;set2_hdls;set3_hdls;];
  473. dw2dhist('select',win_dw2dhist,chk_orig_sig,...
  474.      set1_hdls,set2_hdls,set3_hdls,group_hdls);
  475. dw2dhist('draw',win_dw2dhist,win_dw2dtool,selbox,Chk_App_Lst,Chk_Det_Lst);
  476.         % End waiting.
  477.         %-------------
  478.         set(wfindobj('figure'),'Pointer','arrow');
  479.         set([chk_orig_sig chk_synt_sig chk_app_sig chk_det_sig],'Enable','on');
  480.     case 'select'
  481.         %***********************************************%
  482.         %** OPTION = 'select' - SIGNAL TYPE SELECTION **%
  483.         %***********************************************%
  484.         sel_chk_btn = in3;
  485.         set1_hdls   = in4;
  486.         set2_hdls   = in5;
  487.         set3_hdls   = in6;
  488.         group_hdls  = in7;
  489.         group_hdls  = group_hdls(1:end-1);
  490.         % Get Globals.
  491.         %-------------
  492.         [Def_Btn_Height,Y_Spacing] = ...
  493.             mextglob('get','Def_Btn_Height','Y_Spacing');
  494.         % Handles of tagged objects.
  495.         %---------------------------
  496.         child        = get(win_dw2dhist,'Children');
  497.         axe_handles  = findobj(child,'flat','type','axes');
  498.         uic_handles  = findobj(child,'flat','type','uicontrol');
  499.         chk_handles  = findobj(uic_handles,'flat','Style','checkbox');
  500.         txt_handles  = findobj(uic_handles,'flat','Style','text');
  501.         fra_handles  = findobj(uic_handles,'flat','Style','frame');
  502.         chk_orig_sig = findobj(chk_handles,'Tag',tag_orig_sig);
  503.         chk_synt_sig = findobj(chk_handles,'Tag',tag_synt_sig);
  504.         chk_app_sig  = findobj(chk_handles,'Tag',tag_app_sig);
  505.         chk_det_sig  = findobj(chk_handles,'Tag',tag_det_sig);
  506.         hdl1         = findobj(fra_handles,'Tag',tag_fra_sep);
  507.         hdl2         = findobj(txt_handles,'Tag',tag_status_line);
  508.         hdl3         = axe_handles;
  509.         % Cleaning the graphical part.
  510.         %-----------------------------
  511.         delete([hdl1; hdl2; hdl3]);
  512.         % Get the current selection.
  513.         %---------------------------
  514.         orig_sig = (get(chk_orig_sig,'Userdata')~=0);
  515.         synt_sig = (get(chk_synt_sig,'Userdata')~=0);
  516.         app_sig  = (get(chk_app_sig,'Userdata')~=0);
  517.         det_sig  = (get(chk_det_sig,'Userdata')~=0);
  518.         % Get to the current positions.
  519.         %------------------------------
  520.         pos_det_sig    = get(chk_det_sig,'Position');
  521.         pos_app_txt    = get(set1_hdls(1),'Position');
  522.         pos_app_all    = get(set1_hdls(2),'Position');
  523.         pos_app_none   = get(set1_hdls(3),'Position');
  524.         pos_det_txt    = get(set2_hdls(1),'Position');
  525.         pos_detdir_val = get(set2_hdls(2),'Position');
  526.         pos_det_all    = get(set2_hdls(3),'Position');
  527.         pos_det_none   = get(set2_hdls(4),'Position');
  528.         pos_bins_txt   = get(set3_hdls(1),'Position');
  529.         pos_bins_data  = get(set3_hdls(2),'Position');
  530.         pos_show_hist  = get(set3_hdls(3),'Position');
  531.         pos_close      = get(set3_hdls(4),'Position');
  532.         % Redefine heigth of buttons depending on levels.
  533.         %------------------------------------------------
  534.         levels      = length(set1_hdls)-3;
  535.         nb_inline   = 3;
  536.         hbtn1       = pos_bins_data(4);
  537.         [nul,ypixl] = wfigutil('prop_size',win_dw2dhist,0,1);
  538.         deltay      = min(2*Y_Spacing,0.25*Def_Btn_Height)*ypixl;
  539.         % Redraw the command part depending on the current selection.
  540.         %------------------------------------------------------------
  541.         if sel_chk_btn==chk_orig_sig
  542.             if orig_sig
  543.                 set(chk_orig_sig,'Value',0,'Userdata',0)
  544.                 if ~(synt_sig | app_sig | det_sig) 
  545.                     set(group_hdls,'Visible','off');
  546.                 end
  547.             else
  548.                 set(chk_orig_sig,'Value',1,'Userdata',1)
  549.                 if ~(synt_sig | app_sig | det_sig)
  550.                     pos_bins_txt(2) = pos_det_sig(2)-2*hbtn1;
  551.                     pos_bins_data(2)= pos_bins_txt(2);
  552.                     pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  553.                     set(set3_hdls(1),'Position',pos_bins_txt);
  554.                     set(set3_hdls(2),'Position',pos_bins_data);
  555.                     set(set3_hdls(3),'Position',pos_show_hist);
  556.                     set(set3_hdls,'Visible','on');
  557.                 end
  558.             end
  559.         elseif sel_chk_btn==chk_synt_sig
  560.             if synt_sig
  561.                 set(chk_synt_sig,'Value',0,'Userdata',0)
  562.                 if ~(orig_sig | app_sig | det_sig) 
  563.                     set(group_hdls,'Visible','off');
  564.                 end
  565.             else
  566.                 set(chk_synt_sig,'Value',1,'Userdata',1)
  567.                 if ~(orig_sig | app_sig | det_sig)
  568.                     pos_bins_txt(2) = pos_det_sig(2)-2*hbtn1;
  569.                     pos_bins_data(2)= pos_bins_txt(2);
  570.                     pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  571.                     set(set3_hdls(1),'Position',pos_bins_txt);
  572.                     set(set3_hdls(2),'Position',pos_bins_data);
  573.                     set(set3_hdls(3),'Position',pos_show_hist);
  574.                     set(set3_hdls,'Visible','on');
  575.                 end
  576.             end
  577.         elseif sel_chk_btn==chk_app_sig
  578.             set(group_hdls,'Visible','off');
  579.             if app_sig
  580.                 set(chk_app_sig,'Value',0,'Userdata',0)
  581.                 if (orig_sig | synt_sig) & ~det_sig
  582.                     pos_bins_txt(2) = pos_det_sig(2)-2*hbtn1;
  583.                     pos_bins_data(2)= pos_bins_txt(2);
  584.                     pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  585.                     set(set3_hdls(1),'Position',pos_bins_txt);
  586.                     set(set3_hdls(2),'Position',pos_bins_data);
  587.                     set(set3_hdls(3),'Position',pos_show_hist);
  588.                     set(set3_hdls,'Visible','on');
  589.                 elseif det_sig
  590.                     pos_det_txt(2)  = pos_det_sig(2)-3*hbtn1/2;
  591.                     pos_detdir_val(2) = pos_det_txt(2)-3*hbtn1/2;
  592.                     pos_det_all(2)  = pos_detdir_val(2)-3*hbtn1/2;
  593.                     pos_det_none(2) = pos_det_all(2)-3*hbtn1/2;
  594.                     set(set2_hdls(1),'Position',pos_det_txt);
  595.                     set(set2_hdls(2),'Position',pos_detdir_val);
  596.                     set(set2_hdls(3),'Position',pos_det_all);
  597.                     set(set2_hdls(4),'Position',pos_det_none);
  598.                     pos_chk_det     = zeros(levels,4);
  599.                     for i=1:levels
  600.                         j=i+4;
  601.                         k = ceil(i/nb_inline);
  602.                         pos_chk_det(j,:) = get(set2_hdls(j),'Position');
  603.                         pos_chk_det(j,2) = pos_detdir_val(2)-k*(3*hbtn1/2);
  604.                         set(set2_hdls(j),'Position',pos_chk_det(j,:));
  605.                     end
  606.                     pos_bins_txt(2) = pos_det_txt(2)-6*hbtn1;
  607.                     pos_bins_data(2)= pos_bins_txt(2);
  608.                     yl              = pos_close(2)+pos_close(4);
  609.                     dy              = pos_bins_data(2)-yl-pos_show_hist(4);
  610.                     pos_show_hist(2)= yl+dy/2;
  611.                     set(set3_hdls(1),'Position',pos_bins_txt);
  612.                     set(set3_hdls(2),'Position',pos_bins_data);
  613.                     set(set3_hdls(3),'Position',pos_show_hist);
  614.                     set([set2_hdls;set3_hdls],'Visible','on');
  615.                 end
  616.             else
  617.                 set(chk_app_sig,'Value',1,'Userdata',1)
  618.                 if det_sig
  619.                     pos_app_txt(2)  = pos_det_sig(2)-3*hbtn1/2;
  620.                     pos_app_all(2)  = pos_app_txt(2)-hbtn1-deltay;
  621.                     pos_app_none(2) = pos_app_all(2)-3*hbtn1/2;
  622.                     set(set1_hdls(1),'Position',pos_app_txt);
  623.                     set(set1_hdls(2),'Position',pos_app_all);
  624.                     set(set1_hdls(3),'Position',pos_app_none);
  625.                     pos_det_txt(2)  = pos_app_txt(2)-4.5*hbtn1;
  626.                     pos_detdir_val(2)= pos_det_txt(2)-hbtn1-deltay;
  627.                     pos_det_all(2)  = pos_detdir_val(2)-3*hbtn1/2;
  628.                     pos_det_none(2) = pos_det_all(2)-3*hbtn1/2;
  629.                     set(set2_hdls(1),'Position',pos_det_txt);
  630.                     set(set2_hdls(2),'Position',pos_detdir_val);
  631.                     set(set2_hdls(3),'Position',pos_det_all);
  632.                     set(set2_hdls(4),'Position',pos_det_none);
  633.                     pos_chk_det     = zeros(levels,4);
  634.                     for i=1:levels
  635.                         j=i+4;
  636.                         k = ceil(i/nb_inline);
  637.                         pos_chk_det(j,:) = get(set2_hdls(j),'Position');
  638.                         pos_chk_det(j,2) = pos_detdir_val(2)-k*1.5*hbtn1;
  639.                         set(set2_hdls(j),'Position',pos_chk_det(j,:));
  640.                     end
  641.                     pos_bins_txt(2) = pos_det_txt(2)-6*hbtn1;
  642.                     pos_bins_data(2)= pos_bins_txt(2);
  643.                     yl              = pos_close(2)+pos_close(4);
  644.                     dy              = pos_bins_data(2)-yl-pos_show_hist(4);
  645.                     pos_show_hist(2)= yl+dy/2;
  646.                     set(set3_hdls(1),'Position',pos_bins_txt);
  647.                     set(set3_hdls(2),'Position',pos_bins_data);
  648.                     set(set3_hdls(3),'Position',pos_show_hist);
  649.                     set([set1_hdls;set2_hdls;set3_hdls],'Visible','on');
  650.                 else
  651.                     pos_app_txt(2)  = pos_det_sig(2)-3*hbtn1/2;
  652.                     pos_app_all(2)  = pos_app_txt(2)-hbtn1-deltay;
  653.                     pos_app_none(2) = pos_app_all(2)-3*hbtn1/2;
  654.                     set(set1_hdls(1),'Position',pos_app_txt);
  655.                     set(set1_hdls(2),'Position',pos_app_all);
  656.                     set(set1_hdls(3),'Position',pos_app_none);
  657.                     pos_bins_txt(2) = pos_app_txt(2)-5*hbtn1;
  658.                     pos_bins_data(2)= pos_bins_txt(2);
  659.                     pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  660.                     set(set3_hdls(1),'Position',pos_bins_txt);
  661.                     set(set3_hdls(2),'Position',pos_bins_data);
  662.                     set(set3_hdls(3),'Position',pos_show_hist);
  663.                     set([set1_hdls;set3_hdls],'Visible','on');
  664.                 end
  665.             end
  666.         elseif  sel_chk_btn==chk_det_sig
  667.             set(group_hdls,'Visible','off');
  668.             if det_sig
  669.                 set(chk_det_sig,'Value',0,'Userdata',0)
  670.                 if (orig_sig | synt_sig) & ~app_sig
  671.                     pos_bins_txt(2) = pos_det_sig(2)-2*hbtn1;
  672.                     pos_bins_data(2)= pos_bins_txt(2);
  673.                     pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  674.                     set(set3_hdls(1),'Position',pos_bins_txt);
  675.                     set(set3_hdls(2),'Position',pos_bins_data);
  676.                     set(set3_hdls(3),'Position',pos_show_hist);
  677.                     set(set3_hdls,'Visible','on');
  678.                 elseif app_sig
  679.                     pos_app_txt(2)  = pos_det_sig(2)-3*hbtn1/2;
  680.                     pos_app_all(2)  = pos_app_txt(2)-hbtn1-deltay;
  681.                     pos_app_none(2) = pos_app_all(2)-3*hbtn1/2;
  682.                     set(set1_hdls(1),'Position',pos_app_txt);
  683.                     set(set1_hdls(2),'Position',pos_app_all);
  684.                     set(set1_hdls(3),'Position',pos_app_none);
  685.                     pos_bins_txt(2) = pos_app_txt(2)-5*hbtn1;
  686.                     pos_bins_data(2)= pos_bins_txt(2);
  687.                     pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  688.                     set(set3_hdls(1),'Position',pos_bins_txt);
  689.                     set(set3_hdls(2),'Position',pos_bins_data);
  690.                     set(set3_hdls(3),'Position',pos_show_hist);
  691.                     set([set1_hdls;set3_hdls],'Visible','on');
  692.                 end
  693.             else
  694.                 set(chk_det_sig,'Value',1,'Userdata',1)
  695.                 if app_sig
  696.                     pos_app_txt(2)  = pos_det_sig(2)-3*hbtn1/2;
  697.                     pos_app_all(2)  = pos_app_txt(2)-hbtn1-deltay;
  698.                     pos_app_none(2) = pos_app_all(2)-3*hbtn1/2;
  699.                     set(set1_hdls(1),'Position',pos_app_txt);
  700.                     set(set1_hdls(2),'Position',pos_app_all);
  701.                     set(set1_hdls(3),'Position',pos_app_none);
  702.                     pos_det_txt(2)  = pos_app_txt(2)-4.5*hbtn1;
  703.                     pos_detdir_val(2)= pos_det_txt(2)-hbtn1-deltay;
  704.                     pos_det_all(2)  = pos_detdir_val(2)-3*hbtn1/2;
  705.                     pos_det_none(2) = pos_det_all(2)-3*hbtn1/2;
  706.                     set(set2_hdls(1),'Position',pos_det_txt);
  707.                     set(set2_hdls(2),'Position',pos_detdir_val);
  708.                     set(set2_hdls(3),'Position',pos_det_all);
  709.                     set(set2_hdls(4),'Position',pos_det_none);
  710.                     pos_chk_det     = zeros(levels,4);
  711.                     for i=1:levels
  712.                         j=i+4;
  713.                         k=ceil(i/nb_inline);
  714.                         pos_chk_det(j,:) = get(set2_hdls(j),'Position');
  715.                         pos_chk_det(j,2) = pos_detdir_val(2)-k*(3*hbtn1/2);
  716.                         set(set2_hdls(j),'Position',pos_chk_det(j,:));
  717.                     end
  718.                     pos_bins_txt(2) = pos_det_txt(2)-6*hbtn1;
  719.                     pos_bins_data(2)= pos_bins_txt(2);
  720.                     yl              = pos_close(2)+pos_close(4);
  721.                     dy              = pos_bins_data(2)-yl-pos_show_hist(4);
  722.                     pos_show_hist(2)= yl+dy/2;
  723.                     set(set3_hdls(1),'Position',pos_bins_txt);
  724.                     set(set3_hdls(2),'Position',pos_bins_data);
  725.                     set(set3_hdls(3),'Position',pos_show_hist);
  726.                     set([set1_hdls;set2_hdls;set3_hdls],'Visible','on');
  727.                 else
  728.                     pos_det_txt(2)  = pos_det_sig(2)-3*hbtn1/2;
  729.                     pos_detdir_val(2) = pos_det_txt(2)-hbtn1-deltay;
  730.                     pos_det_all(2)  = pos_detdir_val(2)-3*hbtn1/2;
  731.                     pos_det_none(2) = pos_det_all(2)-3*hbtn1/2;
  732.                     set(set2_hdls(1),'Position',pos_det_txt);
  733.                     set(set2_hdls(2),'Position',pos_detdir_val);
  734.                     set(set2_hdls(3),'Position',pos_det_all);
  735.                     set(set2_hdls(4),'Position',pos_det_none);
  736.                     pos_chk_det     = zeros(levels,4);
  737.                     for i=1:levels
  738.                         j=i+4;
  739.                         k=ceil(i/nb_inline);
  740.                         pos_chk_det(j,:) = get(set2_hdls(j),'Position');
  741.                         pos_chk_det(j,2) = pos_detdir_val(2)-k*(3*hbtn1/2);
  742.                         set(set2_hdls(j),'Position',pos_chk_det(j,:));
  743.                     end
  744.                     pos_bins_txt(2) = pos_det_txt(2)-6*hbtn1;
  745.                     pos_bins_data(2)= pos_bins_txt(2);
  746.                     pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  747.                     set(set3_hdls(1),'Position',pos_bins_txt);
  748.                     set(set3_hdls(2),'Position',pos_bins_data);
  749.                     set(set3_hdls(3),'Position',pos_show_hist);
  750.                     set([set2_hdls;set3_hdls],'Visible','on');
  751.                 end
  752.             end
  753.         end
  754.     case 'draw'
  755.         %*********************************%
  756.         %** OPTION = 'draw' - DRAW AXES **%
  757.         %*********************************%
  758.         win_dw2dtool = in3;
  759.         selbox       = in4;
  760.         Chk_App_Lst  = in5;
  761.         Chk_Det_Lst  = in6;
  762.         % Get Globals.
  763.         %-------------
  764.         [Def_Btn_Height,Def_TxtBkColor,Def_FraBkColor] = ...
  765.             mextglob('get','Def_Btn_Height','Def_TxtBkColor','Def_FraBkColor');
  766.         % Handles of tagged objects.
  767.         %---------------------------
  768.         child          = get(win_dw2dhist,'Children');
  769.         uic_handles    = findobj(child,'flat','type','uicontrol');
  770.         chk_handles    = findobj(uic_handles,'Style','checkbox');
  771.         pop_handles    = findobj(uic_handles,'Style','popupmenu');
  772.         pus_handles    = findobj(uic_handles,'Style','pushbutton');
  773.         edi_handles    = findobj(uic_handles,'Style','edit');
  774.         pus_show_hist  = findobj(pus_handles,'Tag',tag_show_hist);
  775.         chk_orig_sig   = findobj(chk_handles,'Tag',tag_orig_sig);
  776.         chk_synt_sig   = findobj(chk_handles,'Tag',tag_synt_sig);
  777.         chk_app_sig    = findobj(chk_handles,'Tag',tag_app_sig);
  778.         chk_det_sig    = findobj(chk_handles,'Tag',tag_det_sig);
  779.         pop_detdir_val = findobj(pop_handles,'Tag',tag_detdir_val);
  780.         edi_bins_data  = findobj(edi_handles,'Tag',tag_bins_data);
  781.         % Handles of tagged objects continuing.
  782.         %-------------------------------------
  783.         txt_handles = findobj(uic_handles,'Style','text');
  784.         fra_handles = findobj(uic_handles,'Style','frame');
  785.         axe_handles = findobj(child,'flat','type','axes');
  786.         hdl1        = findobj(fra_handles,'Tag',tag_fra_sep);
  787.         hdl2        = findobj(txt_handles,'Tag',tag_status_line);
  788.         hdl3        = axe_handles;
  789.         hdl_frame0  = findobj(fra_handles,'Tag',tag_cmd_frame);
  790.         % Check the bins number.
  791.         %-----------------------
  792.         default_bins    = 50;
  793.         old_params      = get(pus_show_hist,'Userdata');
  794.         if ~isempty(old_params) , default_bins = old_params(1); end
  795.         nb_bins = wstr2num(get(edi_bins_data,'String'));
  796.         if isempty(nb_bins) | nb_bins<2
  797.             nb_bins = default_bins;   
  798.             set(edi_bins_data,'String',sprintf('%.0f',default_bins))
  799.         end
  800.         % Main parameters selection before drawing.
  801.         %------------------------------------------
  802.         orig_sig = (get(chk_orig_sig,'Value')~=0);
  803.         synt_sig = (get(chk_synt_sig,'Value')~=0);
  804.         app_sig  = (get(chk_app_sig,'Value')~=0);
  805.         det_sig  = (get(chk_det_sig,'Value')~=0);
  806.         % Getting memory blocks.
  807.         %-----------------------
  808.         [Img_Name,Wav_Name,Lev_Anal] =  ...
  809.                         wmemtool('rmb',win_dw2dtool,n_param_anal, ...
  810.                                 ind_img_name, ...
  811.                                 ind_wav_name, ...
  812.                                 ind_lev_anal  ...
  813.                                 );
  814.         % Actives apps and dets lists construction.
  815.         %------------------------------------------
  816.         if app_sig
  817.             tmp = get(Chk_App_Lst(1:Lev_Anal),'Value');
  818.             if ~iscell(tmp) , tmp = {tmp}; end
  819.             app_lst = find(cat(2,tmp{:})~=0);
  820.         else
  821.             app_lst = [];
  822.         end
  823.         if det_sig
  824.             tmp = get(Chk_Det_Lst(1:Lev_Anal),'Value');
  825.             if ~iscell(tmp) , tmp = {tmp}; end
  826.             det_lst = find(cat(2,tmp{:})~=0);
  827.         else
  828.             det_lst = [];
  829.         end
  830.         
  831.         % Direction value for details.
  832.         %-----------------------------
  833.         dir_str = get(pop_detdir_val,'String');
  834.         dir_val = get(pop_detdir_val,'Value');
  835.         dir     = lower(dir_str(dir_val,1));
  836.         new_params = [nb_bins orig_sig synt_sig app_sig ...
  837.                       det_sig abs(dir) app_lst det_lst  ...
  838.                       ];
  839.         if ~isempty(axe_handles) & isequal(new_params,old_params)
  840.             return;
  841.         end
  842.         % Deseable new selection.
  843.         %-------------------------
  844.         set([chk_handles;pop_handles;pus_handles;edi_bins_data],'Enable','off');
  845.         % Updating parameters.
  846.         %--------------------- 
  847.         set(pus_show_hist,'Userdata',new_params);
  848.         % Show the status line.
  849.         %----------------------
  850.         wfigtitl('vis',win_dw2dhist,'on');
  851.         % Waiting message.
  852.         %-----------------
  853.         wwaiting('msg',win_dw2dhist,'Wait ... computing');
  854.         % Cleaning the graphical part.
  855.         %-----------------------------
  856.         delete([hdl1; hdl2; hdl3]);
  857.         drawnow;
  858.         % Getting memory blocks.
  859.         %-----------------------
  860.         coefs = wmemtool('rmb',win_dw2dtool,n_coefs,1);
  861.         sizes = wmemtool('rmb',win_dw2dtool,n_sizes,1);
  862.         % Sort and get length of apps. and dets. lists.
  863.         %----------------------------------------------
  864.         app_lst     = sort(app_lst);
  865.         app_lst_len = length(app_lst);
  866.         det_lst     = sort(det_lst);
  867.         det_lst_len = length(det_lst);
  868.         % General graphical parameters initialization.
  869.         %--------------------------------------------
  870.         win_units       = get(win_dw2dtool,'Units');
  871.         if ~strcmp(win_units,'pixels')
  872.         [nul,btn_height] = wfigutil('prop_size',win_dw2dhist,1,Def_Btn_Height);
  873.         end
  874.         pos_win      = get(win_dw2dtool,'Position');
  875.         bdx          = 0.1*pos_win(3);
  876.         bdy          = 0.05*pos_win(4);
  877.         ecy          = 0.03*pos_win(4);
  878.         pos_graph    = wmemtool('rmb',win_dw2dtool,n_miscella,...
  879.                                      ind_graph_area);
  880.         h_graph      = pos_graph(4);
  881.         w_graph      = pos_graph(3);
  882.         pos_graph(2) = pos_graph(2)-btn_height;
  883.         fontsize     = wmachdep('fontsize','normal',9,app_lst_len);
  884.         % Axes construction.
  885.         %-------------------
  886.         n_axeleft  = app_lst_len;
  887.         n_axeright = det_lst_len;
  888.         if orig_sig, n_axeleft = n_axeleft+1; end
  889.         if synt_sig, n_axeleft = n_axeleft+1; end
  890.         if n_axeleft*n_axeright~=0
  891.             w_left  = (w_graph-3*bdx)/2;
  892.             x_left  = pos_graph(1)+bdx;
  893.             w_right = w_left;
  894.             x_right = x_left+w_left+bdx+bdx/5;
  895.             w_fra   = 0.01*pos_win(3);
  896.             x_fra   = pos_graph(1)+(w_graph-w_fra)/2;
  897.             y_fra   = btn_height;
  898.             h_fra   = 1-2*btn_height;
  899.         elseif n_axeleft~=0
  900.             w_left  = w_graph-2*bdx;
  901.             x_left  = pos_graph(1)+bdx;
  902.         elseif n_axeright~=0
  903.             w_right = w_graph-2*bdx;
  904.             x_right = pos_graph(1)+bdx;
  905.         end
  906.         if ~isequal(get(0,'CurrentFigure'),win_dw2dhist)
  907.             figure(win_dw2dhist);
  908.         end
  909.         % Building axes on the left part.
  910.         %--------------------------------
  911.         if n_axeleft~=0
  912.             h_left = (pos_graph(4)-2*bdy-(n_axeleft-1)*ecy)/n_axeleft;
  913.             y_left = pos_graph(2)+bdy;
  914.             axe_left = zeros(1,n_axeleft);
  915.             pos_left = [x_left y_left w_left h_left];
  916.             for k = 1:n_axeleft
  917.                 axe_left(k) = axes(...
  918.                                 'Parent',win_dw2dhist,...
  919.                                 'Unit',win_units,...
  920.                                 'Position',pos_left,...
  921.                                 'Drawmode','fast',...
  922.                                 'Box','On'...
  923.                                 );
  924.                 pos_left(2) = pos_left(2)+pos_left(4)+ecy;
  925.             end
  926.         end
  927.         % Building axes on the right part.
  928.         %---------------------------------
  929.         if n_axeright~=0
  930.             h_right = (pos_graph(4)-2*bdy-(n_axeright-1)*ecy)/n_axeright;
  931.             y_right = pos_graph(2)+bdy;
  932.             axe_right = zeros(1,n_axeright);
  933.             pos_right = [x_right y_right w_right h_right];
  934.             for k = 1:n_axeright
  935.                 axe_right(k) = axes(...
  936.                                 'Parent',win_dw2dhist,...
  937.                                 'Position',pos_right,...
  938.                                 'Unit',win_units,...
  939.                                 'Position',pos_right,...
  940.                                 'Drawmode','fast',...
  941.                                 'Box','On'...
  942.                                 );
  943.                 pos_right(2) = pos_right(2)+pos_right(4)+ecy;
  944.             end
  945.         end
  946.         ind_left  = n_axeleft;
  947.         ind_right = n_axeright;
  948.         % Displaying the image histogram.
  949.         %---------------------------------
  950.         if orig_sig
  951.             curr_img = get(dw2drwcd('r_orig',win_dw2dtool),'Cdata');
  952.             curr_img = curr_img(selbox(3):selbox(4),selbox(1):selbox(2));
  953.             curr_img = curr_img(:);
  954.             curr_color = wtbutils('colors','sig');
  955.             axes(axe_left(ind_left));
  956.             his      = wgethist(curr_img,nb_bins);
  957.             his(2,:) = his(2,:)/length(curr_img);
  958.             wplothis(axe_left(ind_left),his,curr_color);
  959.             set(axe_left(ind_left),'Tag','s','Userdata',curr_img);
  960.             h = txtinaxe('create','s',axe_left(ind_left),'left',...
  961.                                 'on','bold',fontsize);
  962.             set(h,'Units',win_units);
  963.             ind_left = ind_left-1;
  964.         end
  965.         % Displaying the synthesized image histogram.
  966.         %---------------------------------------------
  967.         if synt_sig
  968.             curr_img = get(dw2drwcd('r_synt',win_dw2dtool),'Cdata');
  969.             curr_img = curr_img(selbox(3):selbox(4),selbox(1):selbox(2));
  970.             curr_img = curr_img(:);
  971.             curr_color = wtbutils('colors','ssig');
  972.             axes(axe_left(ind_left));
  973.             his      = wgethist(curr_img,nb_bins);
  974.             his(2,:) = his(2,:)/length(curr_img);
  975.             wplothis(axe_left(ind_left),his,curr_color);
  976.             set(axe_left(ind_left),'Tag','ss');
  977.             set(axe_left(ind_left),'Userdata',curr_img);
  978.             s_i = wmemtool('rmb',win_dw2dtool,n_param_anal,ind_simg_type);
  979.             if     s_i=='ss', str_ss = 'ss';
  980.             elseif s_i=='ds', str_ss = 'ds';
  981.             elseif s_i=='cs', str_ss = 'cs';
  982.             end
  983.             h = txtinaxe('create',str_ss,axe_left(ind_left),'left',...
  984.                                 'on','bold',fontsize);
  985.             set(h,'Units',win_units);
  986.             ind_left = ind_left-1;
  987.         end
  988.         % Displaying the approximations histograms.
  989.         %------------------------------------------
  990.         col_app = wtbutils('colors','app',Lev_Anal);
  991.         for k = app_lst_len:-1:1
  992.             level       = app_lst(k);
  993.             ind_coef    = 1;
  994.             curr_img    = appcoef2(coefs,sizes,Wav_Name,level);
  995.             curr_selbox = ceil(selbox./2^level);
  996.             if curr_selbox(2)-curr_selbox(1)<2 | ...
  997.                curr_selbox(4)-curr_selbox(3)<2
  998.                 f = wwarndlg(['   Not enough approximation ' ...
  999.                          'coefficients remaining at level ' ...
  1000.                          sprintf('%.0f',level)],...
  1001.                         'Wavelet 2-D -- Histograms','block');
  1002.                 ind_coef = 0;
  1003.             else
  1004.                 curr_img = curr_img(curr_selbox(3):curr_selbox(4),...
  1005.                                     curr_selbox(1):curr_selbox(2));
  1006.             end
  1007.             curr_img = curr_img(:);
  1008.             axes(axe_left(ind_left));
  1009.             if ind_coef
  1010.                 curr_color = col_app(level,:);
  1011.                 his        = wgethist(curr_img,nb_bins);
  1012.                 his(2,:)   = his(2,:)/length(curr_img);
  1013.                 wplothis(axe_left(ind_left),his,curr_color);
  1014.                 set(axe_left(ind_left),'Userdata',curr_img);
  1015.             end
  1016.             set(axe_left(ind_left),'Tag',['a' sprintf('%.0f',level)]);
  1017.             h = txtinaxe('create',['a' wnsubstr(level)],...
  1018.                           axe_left(ind_left),'left','on','bold',fontsize);
  1019.             set(h,'Units',win_units);
  1020.             ind_left = ind_left-1;
  1021.         end
  1022.         % Displaying the details histograms.
  1023.         %-----------------------------------
  1024.         col_det = wtbutils('colors','det',Lev_Anal);
  1025.         for k = det_lst_len:-1:1
  1026.             level = det_lst(k);
  1027.             ind_coef = 1;
  1028.             curr_img = detcoef2(dir,coefs,sizes,level);
  1029.             curr_selbox = ceil(selbox./2^level);
  1030.             if curr_selbox(2)-curr_selbox(1)<2 | ...
  1031.                curr_selbox(4)-curr_selbox(3)<2
  1032.                 f = wwarndlg(['   Not enough detail ' ...
  1033.                          'coefficients remaining at level ' ...
  1034.                          sprintf('%.0f',level)],...
  1035.                          'Wavelet 2-D -- Histograms','block');
  1036.                 ind_coef = 0;
  1037.             else
  1038.                 curr_img = curr_img(curr_selbox(3):curr_selbox(4),...
  1039.                                     curr_selbox(1):curr_selbox(2));
  1040.             end
  1041.             curr_img        = curr_img(:);
  1042.             axes(axe_right(ind_right));
  1043.             if ind_coef
  1044.                 curr_color = col_det(level,:);
  1045.                 his        = wgethist(curr_img,nb_bins);
  1046.                 his(2,:)   = his(2,:)/length(curr_img);
  1047.                 wplothis(axe_right(ind_right),his,curr_color);
  1048.                 set(axe_right(ind_right),'Userdata',curr_img);
  1049.             end
  1050.             set(axe_right(ind_right),'Tag',['d' sprintf('%.0f',level)]);
  1051.             h = txtinaxe('create',['d' wnsubstr(level)],...
  1052.                           axe_right(ind_right),'right','on','bold',fontsize);
  1053.             set(h,'Units',win_units);
  1054.             ind_right = ind_right-1;
  1055.         end
  1056.         % Vertical separation.
  1057.         %---------------------
  1058.         if n_axeleft*n_axeright~=0
  1059.             uicontrol('Parent',win_dw2dhist,...
  1060.                       'Style','frame',...
  1061.                       'Unit',win_units,...
  1062.                       'Position',[x_fra,y_fra,w_fra,h_fra],...
  1063.                       'Visible','On',...
  1064.                       'Backgroundcolor',Def_FraBkColor,...
  1065.                       'Tag',tag_fra_sep...
  1066.                       );
  1067.         end
  1068.         % Signals type for the status line display.
  1069.         %------------------------------------------
  1070.         str_sig_type = [];
  1071.         if orig_sig
  1072.             str_sig_type = [str_sig_type 'original image - '];
  1073.         end
  1074.         if synt_sig
  1075.             if      s_i=='ss', str_ss = 'synthesized image';
  1076.             elseif  s_i=='ds', str_ss = 'de_noised image';
  1077.             elseif  s_i=='cs', str_ss = 'compressed image';
  1078.             end
  1079.             str_sig_type = [str_sig_type str_ss ' - '];
  1080.         end
  1081.         if (app_sig & ~isempty(app_lst)) | (det_sig & ~isempty(det_lst))
  1082.             str_dir = deblankl(dir_str(dir_val,:));
  1083.             if app_sig & ~isempty(app_lst) & det_sig & ~isempty(det_lst)
  1084.                 str_sig_type = [str_sig_type ...
  1085.                                 'approximations and ' ...
  1086.                                 str_dir ' details'];
  1087.             elseif (app_sig & ~isempty(app_lst)) & (~det_sig | isempty(det_lst))
  1088.                 str_sig_type = [str_sig_type 'approximations'];
  1089.             elseif (~app_sig | isempty(app_lst)) & (det_sig & ~isempty(det_lst))
  1090.                 str_sig_type = [str_sig_type str_dir ' details'];
  1091.             end
  1092.             str_sig_type = [str_sig_type ' coefficients'];
  1093.         end
  1094.         if ~orig_sig & ~synt_sig           & ...
  1095.            (~app_sig | isempty(app_lst))   & ...
  1096.            (~det_sig | isempty(det_lst))
  1097.             str_sig_type = 'Nothing selected';
  1098.         end
  1099.         txt_sig_type = uicontrol('Parent',win_dw2dhist,...
  1100.                                 'Style','text',...
  1101.                                 'Unit',win_units,...
  1102.                                 'Position',[0,0,w_graph,btn_height],...
  1103.                                 'Visible','On',...
  1104.                                 'Backgroundcolor',Def_TxtBkColor,...
  1105.                                 'String',str_sig_type,...
  1106.                                 'Tag',tag_status_line...
  1107.                                 );
  1108.         % Setting units to normalized.
  1109.         %-----------------------------
  1110.         set(findobj(win_dw2dhist,'Units','pixels'),'Units','normalized');
  1111.         % End waiting.
  1112.         %-------------
  1113.         wwaiting('off',win_dw2dhist);
  1114.         % Enable new selection.
  1115.         %-------------------------
  1116.         set([chk_handles;pop_handles;pus_handles;edi_bins_data],'Enable','on');
  1117.     case 'update_bins'
  1118.         %**************************************************************%
  1119.         %** OPTION = 'update_bins' - UPDATE HISTOGRAMS WITH NEW BINS **%
  1120.         %**************************************************************%
  1121.         edi_bins_data = in3;
  1122.         % Handles of tagged objects.
  1123.         %---------------------------
  1124.         pus_show_hist = findobj(win_dw2dhist,...
  1125.                                       'Style','pushbutton',...
  1126.                                       'Tag',tag_show_hist...
  1127.                                       );
  1128.         axes_hdls   = findobj(get(win_dw2dhist,'Children'),'flat','type','axes');
  1129.         Sigtype_hdl = findobj(win_dw2dhist,'Style','text','Tag',tag_status_line);
  1130.         if isempty(axes_hdls) , return; end
  1131.         % Check the bins number.
  1132.         %-----------------------
  1133.         default_bins = 50;
  1134.         old_params   = get(pus_show_hist,'Userdata');
  1135.         if ~isempty(old_params) , default_bins = old_params(1); end
  1136.         nb_bins = wstr2num(get(edi_bins_data,'String'));
  1137.         if isempty(nb_bins) | nb_bins<2
  1138.             nb_bins = default_bins;   
  1139.             set(edi_bins_data,'String',sprintf('%.0f',default_bins))
  1140.         end
  1141.         if default_bins==nb_bins , return; end
  1142.         % Waiting message.
  1143.         %-----------------
  1144.         set(Sigtype_hdl,'Visible','off');
  1145.         wwaiting('msg',win_dw2dhist,'Wait ... computing');
  1146.         % Updating histograms.
  1147.         %---------------------
  1148.         old_params(1) = nb_bins;
  1149.         set(pus_show_hist,'Userdata',old_params);
  1150.         nb_axes = length(axes_hdls);
  1151.         fontsize = wmachdep('fontsize','normal',9,nb_axes);
  1152.         for i=1:nb_axes
  1153.             curr_axe = axes_hdls(i);
  1154.             curr_img = get(curr_axe,'Userdata');
  1155.             if ~isempty(curr_img)
  1156.                 axes(curr_axe);
  1157.                 curr_child = findobj(get(curr_axe,'Children'),'type','patch');
  1158.                 axe_col    = get(curr_child,'FaceColor');
  1159.                 his        = wgethist(curr_img,nb_bins);
  1160.                 his(2,:)   = his(2,:)/length(curr_img);
  1161.                 wplothis(curr_axe,his,axe_col);
  1162.                 curr_txt   = get(curr_axe,'tag');
  1163.                 switch curr_txt(1)
  1164.                   case {'a','d'}
  1165.                     curr_txt = [curr_txt(1), wnsubstr(curr_txt(2:end))];
  1166.                 end
  1167.                 if curr_txt(1)=='d'
  1168.                     txtinaxe('create',curr_txt,curr_axe,'right',...
  1169.                                     'on','bold',fontsize);
  1170.                 else
  1171.                     txtinaxe('create',curr_txt,curr_axe,'left',...
  1172.                                     'on','bold',fontsize);
  1173.                 end
  1174.                 set(curr_axe,'Userdata',curr_img)
  1175.             end
  1176.         end
  1177.         % End waiting.
  1178.         %-------------
  1179.         wwaiting('off',win_dw2dhist);
  1180.         set(Sigtype_hdl,'Visible','on');
  1181.     case 'demo'
  1182.         %****************************************%
  1183.         %** OPTION = 'demo' -  DEMOS or TESTS  **%
  1184.         %****************************************%
  1185.         chk_handles   = findobj(win_dw2dhist,'Style','checkbox');
  1186.         chk_orig_sig  = findobj(chk_handles,'Tag',tag_orig_sig);
  1187.         chk_synt_sig  = findobj(chk_handles,'Tag',tag_synt_sig);
  1188.         chk_app_sig   = findobj(chk_handles,'Tag',tag_app_sig);
  1189.         chk_det_sig   = findobj(chk_handles,'Tag',tag_det_sig);
  1190.         pus_show_hist = findobj(win_dw2dhist,...
  1191.                                       'Style','pushbutton',...
  1192.                                       'Tag',tag_show_hist...
  1193.                                       );
  1194.         set(chk_handles,'Value',1);
  1195.         eval(get(chk_orig_sig,'Callback'));
  1196.         eval(get(chk_synt_sig,'Callback'));
  1197.         eval(get(chk_app_sig,'Callback'));
  1198.         eval(get(chk_det_sig,'Callback'));
  1199.         eval(get(pus_show_hist,'Callback'));
  1200.     case 'close'
  1201.     otherwise
  1202.         errargt(mfilename,'Unknown Option','msg');
  1203.         error('*');
  1204. end
  1205. %-------------------------------------------------
  1206. function varargout = depOfMachine(varargin)
  1207. Def_Btn_Height = varargin{1};
  1208. scrSize = get(0,'ScreenSize');
  1209. if scrSize(4)<700
  1210.     chk_heigth = Def_Btn_Height;
  1211. else
  1212.     chk_heigth = 3*Def_Btn_Height/2;
  1213. end
  1214. dy1_chk = Def_Btn_Height/4;
  1215. dy_chk  = Def_Btn_Height/2;
  1216. varargout = {chk_heigth,dy1_chk,dy_chk};
  1217. %-------------------------------------------------