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

波变换

开发平台:

Matlab

  1. function varargout = imgxtool(option,varargin)
  2. %IMGXTOOL Image extension tool.
  3. %   VARARGOUT = IMGXTOOL(OPTION,VARARGIN)
  4. %
  5. %   GUI oriented tool which allows the construction of a new
  6. %   image from an original one by truncation or extension.
  7. %   Extension is done by selecting different possible modes:
  8. %   Symmetric, Periodic, Zero Padding, Continuous or Smooth.
  9. %   A special mode is provided to extend an image in order 
  10. %   to be accepted by the SWT decomposition.
  11. %------------------------------------------------------------
  12. %   Internal options:
  13. %
  14. %   OPTION = 'create'          'load'             'demo'
  15. %            'update_deslen'   'extend_truncate'
  16. %            'draw'            'save'
  17. %            'clear_graphics'  'mode'
  18. %            'close'
  19. %
  20. %   See also WEXTEND.
  21. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 30-Nov-98.
  22. %   Last Revision: 14-Jul-2003.
  23. %   Copyright 1995-2004 The MathWorks, Inc.
  24. %   $Revision: 1.12.4.2 $  $Date: 2004/03/15 22:40:45 $
  25. % Test inputs.
  26. %-------------
  27. if nargin==0 , option = 'create'; end
  28. [option,winAttrb] = utguidiv('ini',option,varargin{:});
  29. % Default values.
  30. %----------------
  31. default_nbcolors = 255;
  32. % Image Coding Value.
  33. %-------------------
  34. codemat_v = wimgcode('get');
  35. % Initialisations for all options excepted 'create'.
  36. %---------------------------------------------------
  37. switch option
  38.   case 'create'
  39.   
  40.   otherwise
  41.     % Get figure handle.
  42.     %-------------------
  43.     win_imgxtool = varargin{1};
  44.     % Get stored structure.
  45.     %----------------------
  46.     Hdls_UIC_C      = wfigmngr('getValue',win_imgxtool,'Hdls_UIC_C');
  47.     Hdls_UIC_H      = wfigmngr('getValue',win_imgxtool,'Hdls_UIC_H');
  48.     Hdls_UIC_V      = wfigmngr('getValue',win_imgxtool,'Hdls_UIC_V');
  49.     Hdls_UIC_Swt    = wfigmngr('getValue',win_imgxtool,'Hdls_UIC_Swt');
  50.     Hdls_Axes       = wfigmngr('getValue',win_imgxtool,'Hdls_Axes');
  51.     Hdls_Colmap     = wfigmngr('getValue',win_imgxtool,'Hdls_Colmap');
  52.     Pos_Axe_Img_Ori = wfigmngr('getValue',win_imgxtool,'Pos_Axe_Img_Ori');
  53.  
  54.     % Get UIC Handles.
  55.     %-----------------
  56.     [m_load,m_save,m_demo,txt_image,edi_image,...
  57.      txt_mode,pop_mode,pus_extend] = deal(Hdls_UIC_C{:});
  58.  
  59.     [frm_fra_H,txt_fra_H,txt_length_H,edi_length_H,txt_nextpow2_H,  ...
  60.      edi_nextpow2_H,txt_prevpow2_H,edi_prevpow2_H,txt_deslen_H,     ...
  61.      edi_deslen_H,txt_direct_H,pop_direct_H] = deal(Hdls_UIC_H{:});
  62.  
  63.     [frm_fra_V,txt_fra_V,txt_length_V,edi_length_V,txt_nextpow2_V,  ...
  64.      edi_nextpow2_V,txt_prevpow2_V,edi_prevpow2_V,txt_deslen_V,     ...
  65.      edi_deslen_V,txt_direct_V,pop_direct_V] = deal(Hdls_UIC_V{:});
  66.  
  67.     [txt_swtdec,pop_swtdec,frm_fra_H_2,txt_fra_H_2,txt_swtlen_H,    ...
  68.      edi_swtlen_H,txt_swtclen_H,edi_swtclen_H,txt_swtdir_H,         ...
  69.      edi_swtdir_H,txt_swtdec,pop_swtdec,frm_fra_V_2,txt_fra_V_2,    ...
  70.      txt_swtlen_V,edi_swtlen_V,txt_swtclen_V,edi_swtclen_V,         ...
  71.      txt_swtdir_V,edi_swtdir_V] = deal(Hdls_UIC_Swt{:});
  72. end
  73. % Process control depending on the calling option.
  74. %-------------------------------------------------
  75. switch option
  76.     case 'create'
  77.     %-------------------------------------------------------%
  78.     % Option: 'CREATE' - Create Figure, Uicontrols and Axes %
  79.     %-------------------------------------------------------%
  80.         % Get Globals.
  81.         %-------------
  82.         [Def_Btn_Height,Def_Btn_Width,Pop_Min_Width,X_Graph_Ratio, ...
  83.         X_Spacing,Y_Spacing,Def_TxtBkColor,Def_EdiBkColor,         ...
  84.         Def_FraBkColor] =                                          ...
  85.                 mextglob('get',                                    ...
  86.                 'Def_Btn_Height','Def_Btn_Width','Pop_Min_Width',  ...
  87.                 'X_Graph_Ratio','X_Spacing','Y_Spacing',           ...
  88.                 'Def_TxtBkColor','Def_EdiBkColor','Def_FraBkColor' ...
  89.                 );
  90.         % Window initialization.
  91.         %-----------------------
  92.         [win_imgxtool,pos_win,win_units,str_numwin,                ...
  93.         frame0,pos_frame0,Pos_Graphic_Area,pus_close] =            ...
  94.                 wfigmngr('create','Image Extension / Truncation',  ...
  95.                          winAttrb,'ExtFig_Tool_3',                 ...
  96.                          strvcat(mfilename,'cond'),1,1,0);
  97.         if nargout>0 , varargout{1} = win_imgxtool; end
  98. % Add Help for Tool.
  99. %------------------
  100. wfighelp('addHelpTool',win_imgxtool, ...
  101. 'Two-Dimensional &Extension','IMGX_GUI');
  102. % Add Help Item.
  103. %----------------
  104. wfighelp('addHelpItem',win_imgxtool,...
  105. 'Dealing with Border Distortion','BORDER_DIST');
  106.         % Menu construction for current figure.
  107.         %--------------------------------------
  108.         m_files = wfigmngr('getmenus',win_imgxtool,'file');
  109.         m_load  = uimenu(m_files, ...
  110.                          'Label','&Load Image',                    ...
  111.                          'Position',1,                             ...
  112.                          'Callback',                               ...
  113.                          [mfilename '(''load'',' str_numwin ');']  ...
  114.                          );
  115.         m_save  = uimenu(m_files,...
  116.                          'Label','&Save Transformed Image',       ...
  117.                          'Position',2,                            ...
  118.                          'Enable','Off',                          ...
  119.                          'Callback',                              ...
  120.                          [mfilename '(''save'',' str_numwin ');'] ...
  121.                          );
  122.         m_demo  = uimenu(m_files, ...
  123.                          'Label','&Example Extension','Position',3);
  124.         demoSET = {...
  125.          'woman2'  , 'ext'   , '{''zpd'' , [220,200] , ''both'' , ''both''}' ; ...
  126.          'woman2'  , 'trunc' , '{''nul'' , [ 96, 96] , ''both'' , ''both''}' ; ...
  127.          'wbarb'   , 'ext'   , '{''sym'' , [512,200] , ''right'', ''both''}' ; ...
  128.          'noiswom' , 'ext'   , '{''sym'' , [512,512] , ''right'', ''down''}' ; ...
  129.          'noiswom' , 'ext'   , '{''ppd'' , [512,512] , ''right'', ''down''}' ; ...
  130.          'wbarb'   , 'ext'   , '{''sym'' , [512,512] , ''both'' , ''both''}' ; ...
  131.          'facets'  , 'ext'   , '{''ppd'' , [512,512] , ''both'' , ''both''}' ; ...
  132.          'mandel'  , 'ext'   , '{''sym'' , [512,512] , ''left'' , ''both''}'   ...
  133.          };
  134.         nbDEM = size(demoSET,1);
  135.         beg_call_str = [mfilename '(''demo'',' str_numwin ','''];
  136. dummy = demoSET(:,1);
  137. names = strvcat(dummy{:});
  138. tab   = setstr(9);
  139.         for k = 1:nbDEM
  140.             typ = demoSET{k,2};
  141.             fil = demoSET{k,1};
  142.             par = demoSET{k,3};
  143.             parVal = eval(par);
  144.             switch parVal{1}
  145.               case 'swt'
  146.                 lenSTR = [' - level: ',int2str(parVal{2})];
  147.               otherwise
  148.                 siz = fliplr(parVal{2}); 
  149.                 lenSTR = [' - size: [' , int2str(parVal{2}) , ']'];
  150.             end
  151.             strPAR = ['mode: ' ,  parVal{1} , lenSTR, ...
  152.                       ' - direction: [', parVal{3} , ',' parVal{4} ,']'];
  153.             switch  typ
  154.               case 'ext'   , strTYPE = ['Extension  - '];
  155.               case 'trunc' , strTYPE = ['Truncation - '];
  156.             end
  157.             libel = [names(k,:) tab '  -  ' strTYPE strPAR];
  158.             action = [beg_call_str fil  ''',''' typ ''',' par ');'];
  159.             uimenu(m_demo,'Label',libel,'Callback',action);
  160.         end
  161.         % Begin waiting.
  162.         %---------------
  163.         wwaiting('msg',win_imgxtool,'Wait ... initialization');
  164.         % Borders and double borders.
  165.         %----------------------------
  166.         dx = X_Spacing; dx2 = 2*dx;
  167.         dy = Y_Spacing; dy2 = 2*dy;
  168.         % General graphical parameters initialization.
  169.         %--------------------------------------------
  170.         x_frame0  = pos_frame0(1);
  171.         cmd_width = pos_frame0(3);
  172.         pus_width = cmd_width-4*dx2;
  173.         txt_width = 3*Def_Btn_Width/2;
  174.         edi_width = 3*Def_Btn_Width/4;
  175.         pop_width = 7*Def_Btn_Width/4;
  176.         bdx       = 0.08*pos_win(3);
  177.         bdy       = 0.06*pos_win(4);
  178.         ecy       = 0.03*pos_win(4);
  179.         x_graph   = bdx;
  180.         y_graph   = 2*Def_Btn_Height+dy;
  181.         h_graph   = pos_frame0(4)-y_graph;
  182.         w_graph   = pos_frame0(1);
  183.         % Command part of the window.
  184.         %============================
  185.         % Position property of objects.
  186.         %------------------------------
  187.         xlocINI            = [x_frame0 cmd_width];
  188.         ybottomINI         = pos_win(4)-dy2;
  189.         x_left_INI         = x_frame0+dx2+dx;
  190.         x_left             = x_left_INI;
  191.         y_low              = ybottomINI-(Def_Btn_Height+1*dy2);
  192.         pos_txt_image      = [x_left, y_low, txt_width Def_Btn_Height];
  193.         x_left             = x_left+txt_width/2+3*dx;
  194.         pos_edi_image      = [x_left, y_low+dy/2, 2*edi_width, ...
  195.                                Def_Btn_Height];
  196.         x_left             = x_left_INI;
  197.         y_low              = y_low-1.5*(Def_Btn_Height+2*dy2);
  198.         pos_txt_length_H   = [x_left, y_low, txt_width Def_Btn_Height];
  199.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  200.         pos_edi_length_H   = [x_left, y_low+dy/2, edi_width , Def_Btn_Height];
  201.         x_left             = x_left_INI;
  202.         y_low              = y_low-(Def_Btn_Height+1*dy2);
  203.         pos_txt_nextpow2_H = [x_left, y_low, txt_width Def_Btn_Height];
  204.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  205.         pos_edi_nextpow2_H = [x_left, y_low+dy/2, edi_width , Def_Btn_Height];
  206.         x_left             = x_left_INI;
  207.         y_low              = y_low-(Def_Btn_Height+1*dy2);
  208.         pos_txt_prevpow2_H = [x_left, y_low, txt_width Def_Btn_Height];
  209.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  210.         pos_edi_prevpow2_H = [x_left, y_low+dy/2, edi_width , Def_Btn_Height];
  211.         x_left             = x_left_INI;
  212.         y_low              = y_low-(Def_Btn_Height+1*dy2);
  213.         pos_txt_deslen_H   = [x_left, y_low, txt_width Def_Btn_Height];
  214.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  215.         pos_edi_deslen_H   = [x_left, y_low+dy/2, edi_width , Def_Btn_Height];
  216.         x_left             = x_left_INI;
  217.         y_low              = y_low-(Def_Btn_Height+1*dy2);
  218.         pos_txt_direct_H   = [x_left, y_low, txt_width, Def_Btn_Height];
  219.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  220.         pos_pop_direct_H   = [x_left, y_low+dy/2, edi_width , Def_Btn_Height];
  221.         fra_left           = x_left_INI-dx2;
  222.         fra_low            = y_low-dy;
  223.         fra_width          = cmd_width-dx2;
  224.         fra_heigth         = 5*(Def_Btn_Height+1*dy2)+dy2;
  225.         pos_fra_H          = [fra_left, fra_low, fra_width, fra_heigth];
  226.         txt_fra_H_heigth   = 3 * Def_Btn_Height / 4;
  227.         txt_fra_H_width    = Def_Btn_Width;
  228.         txt_fra_H_low      = (fra_low + fra_heigth) - (txt_fra_H_heigth / 2);
  229.         txt_fra_H_left     = fra_left + (fra_width - txt_fra_H_width) / 2;
  230.         pos_txt_fra_H      = [txt_fra_H_left, txt_fra_H_low, ...
  231.                                txt_fra_H_width, txt_fra_H_heigth];
  232.  
  233.         x_left             = x_left_INI;
  234.         y_low              = fra_low-1.5*(Def_Btn_Height+2*dy2);
  235.         pos_txt_length_V   = [x_left, y_low, txt_width Def_Btn_Height];
  236.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  237.         pos_edi_length_V   = [x_left, y_low+dy, edi_width , Def_Btn_Height];
  238.         x_left             = x_left_INI;
  239.         y_low              = y_low-(Def_Btn_Height+1*dy2);
  240.         pos_txt_nextpow2_V = [x_left, y_low, txt_width Def_Btn_Height];
  241.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  242.         pos_edi_nextpow2_V = [x_left, y_low+dy/2, edi_width , Def_Btn_Height];
  243.         x_left             = x_left_INI;
  244.         y_low              = y_low-(Def_Btn_Height+1*dy2);
  245.         pos_txt_prevpow2_V = [x_left, y_low, txt_width Def_Btn_Height];
  246.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  247.         pos_edi_prevpow2_V = [x_left, y_low+dy/2, edi_width , Def_Btn_Height];
  248.         x_left             = x_left_INI;
  249.         y_low              = y_low-(Def_Btn_Height+1*dy2);
  250.         pos_txt_deslen_V   = [x_left, y_low, txt_width Def_Btn_Height];
  251.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  252.         pos_edi_deslen_V   = [x_left, y_low+dy/2, edi_width , Def_Btn_Height];
  253.         x_left             = x_left_INI;
  254.         y_low              = y_low-(Def_Btn_Height+1*dy2);
  255.         pos_txt_direct_V   = [x_left, y_low, txt_width, Def_Btn_Height];
  256.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  257.         pos_pop_direct_V   = [x_left, y_low+dy/2, edi_width , Def_Btn_Height];
  258.  
  259.         fra_left           = x_left_INI-dx2;
  260.         fra_low            = y_low-dy;
  261.         fra_width          = cmd_width-dx2;
  262.         fra_heigth         = 5*(Def_Btn_Height+1*dy2)+dy2;
  263.         pos_fra_V          = [fra_left, fra_low, fra_width, fra_heigth];
  264.         txt_fra_V_heigth   = 3 * Def_Btn_Height / 4;
  265.         txt_fra_V_width    = Def_Btn_Width;
  266.         txt_fra_V_low      = (fra_low + fra_heigth) - (txt_fra_V_heigth / 2);
  267.         txt_fra_V_left     = fra_left + (fra_width - txt_fra_V_width) / 2;
  268.         pos_txt_fra_V      = [txt_fra_V_left, txt_fra_V_low, ...
  269.                                txt_fra_V_width, txt_fra_V_heigth];
  270.         x_left             = x_left_INI-dx2+(cmd_width-3*txt_width/4)/2;
  271.         y_low              = fra_low-(Def_Btn_Height+1*dy2);
  272.         pos_txt_mode       = [x_left, y_low, txt_width Def_Btn_Height];
  273.  
  274.         x_left             = x_left_INI+dx2;
  275.         y_low              = y_low-(Def_Btn_Height+dy);
  276.         pos_pop_mode       = [x_left, y_low, pus_width , Def_Btn_Height];
  277.         x_left             = x_left_INI+dx2;
  278.         y_low              = y_low-2*Def_Btn_Height-dy;
  279.         pos_pus_extend     = [x_left, y_low, pus_width , 1.5*Def_Btn_Height];
  280.         pos_fra_H_2        = pos_fra_H;
  281.         pos_fra_H_2(2)     = pos_fra_H(2)-Def_Btn_Height;
  282.         pos_fra_H_2(4)     = 3*(Def_Btn_Height+2*dy2)+dy;
  283.         txt_fra_H_heigth   = 3 * Def_Btn_Height / 4;
  284.         txt_fra_H_width    = Def_Btn_Width;
  285.         txt_fra_H_low      = (pos_fra_H_2(2)+pos_fra_H_2(4))-               ...
  286.                              (txt_fra_H_heigth / 2);
  287.         txt_fra_H_left     = pos_fra_H_2(1)+(pos_fra_H_2(3)-txt_fra_H_width)...
  288.                              / 2;
  289.         pos_txt_fra_H_2    = [txt_fra_H_left, txt_fra_H_low, ...
  290.                                txt_fra_H_width, txt_fra_H_heigth];
  291.  
  292.         x_left             = x_left_INI-dx2;
  293.         y_low              = pos_fra_H_2(2)+pos_fra_H_2(4)+3*dy2;
  294.         pos_txt_swtdec     = [x_left, y_low, 3*txt_width/2, Def_Btn_Height];
  295.         x_left             = x_left+txt_width/2+edi_width+3*dx+dx2;
  296.         pos_pop_swtdec     = [x_left, y_low+dy, edi_width, Def_Btn_Height];
  297.  
  298.         x_left             = x_left_INI;
  299.         y_low              = pos_fra_H_2(2)+pos_fra_H_2(4)-(Def_Btn_Height+ ...
  300.                              2*dy2);
  301.         pos_txt_swtlen_H   = [x_left, y_low, txt_width, Def_Btn_Height];
  302.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  303.         pos_edi_swtlen_H   = [x_left, y_low+dy, edi_width, Def_Btn_Height];
  304.  
  305.         x_left             = x_left_INI;
  306.         y_low              = y_low-(Def_Btn_Height+2*dy2);
  307.         pos_txt_swtclen_H  = [x_left, y_low, txt_width, Def_Btn_Height];
  308.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  309.         pos_edi_swtclen_H  = [x_left, y_low+dy, edi_width, Def_Btn_Height];
  310.  
  311.         x_left             = x_left_INI;
  312.         y_low              = y_low-(Def_Btn_Height+2*dy2);
  313.         pos_txt_swtdir_H   = [x_left, y_low, txt_width, Def_Btn_Height];
  314.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  315.         pos_edi_swtdir_H   = [x_left, y_low+dy, edi_width, Def_Btn_Height];
  316.  
  317.         pos_fra_V_2        = pos_fra_V;
  318.         pos_fra_V_2(4)     = 3*(Def_Btn_Height+2*dy2)+dy;
  319.         txt_fra_V_heigth   = 3 * Def_Btn_Height / 4;
  320.         txt_fra_V_width    = Def_Btn_Width;
  321.         txt_fra_V_low      = (pos_fra_V_2(2)+pos_fra_V_2(4))-               ...
  322.                              (txt_fra_V_heigth / 2);
  323.         txt_fra_V_left     = pos_fra_V_2(1)+(pos_fra_V_2(3)-txt_fra_V_width)...
  324.                              / 2;
  325.         pos_txt_fra_V_2    = [txt_fra_V_left, txt_fra_V_low, ...
  326.                                txt_fra_V_width, txt_fra_V_heigth];
  327.  
  328.         x_left             = x_left_INI;
  329.         y_low              = pos_fra_V_2(2)+pos_fra_V_2(4)-(Def_Btn_Height+ ...
  330.                              2*dy2);
  331.         pos_txt_swtlen_V   = [x_left, y_low, txt_width, Def_Btn_Height];
  332.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  333.         pos_edi_swtlen_V   = [x_left, y_low+dy, edi_width, Def_Btn_Height];
  334.  
  335.         x_left             = x_left_INI;
  336.         y_low              = y_low-(Def_Btn_Height+2*dy2);
  337.         pos_txt_swtclen_V  = [x_left, y_low, txt_width, Def_Btn_Height];
  338.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  339.         pos_edi_swtclen_V  = [x_left, y_low+dy, edi_width, Def_Btn_Height];
  340.  
  341.         x_left             = x_left_INI;
  342.         y_low              = y_low-(Def_Btn_Height+2*dy2);
  343.         pos_txt_swtdir_V   = [x_left, y_low, txt_width, Def_Btn_Height];
  344.         x_left             = x_left+txt_width/2+edi_width+3*dx;
  345.         pos_edi_swtdir_V   = [x_left, y_low+dy, edi_width, Def_Btn_Height];
  346.         % String property of objects.
  347.         %----------------------------
  348.         str_txt_image    = 'Image';
  349.         str_edi_image    = '';
  350.         str_txt_length   = 'Length';
  351.         str_edi_length   = '';
  352.         str_txt_nextpow2 = 'Next Power of 2';
  353.         str_edi_nextpow2 = '';
  354.         str_txt_prevpow2 = 'Previous Power of 2';
  355.         str_edi_prevpow2 = '';
  356.         str_txt_deslen   = 'Desired Length';
  357.         str_edi_deslen   = '';
  358.         str_txt_direct   = 'Direction to extend';
  359.         str_pop_direct_H = [ 'Both ' ; 'Left ' ; 'Right'];
  360.         str_pop_direct_V = [ 'Both ' ; 'Up   ' ; 'Down '];
  361.         str_txt_fra_H    = 'Horizontal';
  362.         str_txt_fra_H_2  = 'Horizontal';
  363.         str_txt_fra_V    = 'Vertical';
  364.         str_txt_fra_V_2  = 'Vertical';
  365.         str_txt_mode     = 'Extension Mode';
  366.         str_pop_mode     = strvcat(...
  367.                             'Symmetric (Half-Point)', ...
  368.                             'Symmetric (Whole-Point)', ...
  369.                             'Antisymmetric (Half-Point)', ...
  370.                             'Antisymmetric (Whole-Point)', ...                            
  371.                             'Periodic', ... 
  372.                             'Zero Padding', ... 
  373.                             'Continuous', ... 
  374.                             'Smooth', ... 
  375.                             'For SWT'  ... 
  376.                             );
  377.         str_pus_extend    = 'Extend';
  378.         str_txt_swtdec    = 'SWT Decomposition Level';
  379.         str_pop_swtdec    = num2str((1:10)');
  380.         str_txt_swtlen_H  = 'Length';
  381.         str_edi_swtlen_H  = '';
  382.         str_txt_swtclen_H = 'Computed Length';
  383.         str_edi_swtclen_H = '';
  384.         str_txt_swtdir_H  = 'Direction to extend';
  385.         str_edi_swtdir_H  = 'Right';
  386.         str_tip_swtclen_H = strvcat(['Minimal length of the ',     ...
  387.                                      'periodic extended signal ',  ...
  388.                                      'for SWT decomposition']);
  389.         str_tip_swtclen_V = str_tip_swtclen_H;
  390.         str_txt_swtlen_V  = 'Length';
  391.         str_edi_swtlen_V  = '';
  392.         str_txt_swtclen_V = 'Computed Length';
  393.         str_edi_swtclen_V = '';
  394.         str_txt_swtdir_V  = 'Direction to extend';
  395.         str_edi_swtdir_V  = 'Down';
  396.  
  397.         % Construction of uicontrols.
  398.         %----------------------------
  399.         commonProp = {...
  400.                       'Parent',win_imgxtool, ...
  401.                       'Unit',win_units,      ...
  402.                       'Visible','off'        ...
  403.                       };
  404.         comFraProp = {commonProp{:}, ...
  405.                       'BackGroundColor',Def_FraBkColor, ...
  406.                       'Style','frame'                   ...
  407.                       };
  408.         comPusProp = {commonProp{:},'Style','Pushbutton'};
  409.         comPopProp = {commonProp{:},'Style','Popupmenu'};
  410.         comTxtProp = {commonProp{:}, ...
  411.                       'ForeGroundColor','k',            ...
  412.                       'BackGroundColor',Def_FraBkColor, ...
  413.                       'HorizontalAlignment','left',     ...
  414.                       'Style','Text'                    ...
  415.                       };
  416.         comEdiProp = {commonProp{:}, ...
  417.                       'ForeGroundColor','k',          ...
  418.                       'HorizontalAlignment','center', ...
  419.                       'Style','Edit'                  ...
  420.                       };
  421.         
  422.         txt_image      = uicontrol(                                   ...
  423.                                    comTxtProp{:},                     ...
  424.                                    'Position',pos_txt_image,          ...
  425.                                    'String',str_txt_image             ...
  426.                                    );
  427.         edi_image      = uicontrol(                                   ...
  428.                                    comEdiProp{:},                     ...
  429.                                    'Position',pos_edi_image,          ...
  430.                                    'String',str_edi_image,            ...
  431.                                    'BackGroundColor',Def_FraBkColor,  ...
  432.                                    'Enable','Inactive'                ...
  433.                                    );
  434.         frm_fra_H      = uicontrol(                                   ...
  435.                                    comFraProp{:},                     ...
  436.                                    'Position',pos_fra_H               ...
  437.                                    );
  438.         txt_fra_H      = uicontrol(                                   ...
  439.                                    comTxtProp{:},                     ...
  440.                                    'HorizontalAlignment','center',    ...
  441.                                    'Position',pos_txt_fra_H,          ...
  442.                                    'String',str_txt_fra_H             ...
  443.                                    );
  444.         txt_length_H   = uicontrol(                                   ...
  445.                                    comTxtProp{:},                     ...
  446.                                    'Position',pos_txt_length_H,       ...
  447.                                    'String',str_txt_length            ...
  448.                                    );
  449.         edi_length_H   = uicontrol(                                   ...
  450.                                    comEdiProp{:},                     ...
  451.                                    'Position',pos_edi_length_H,       ...
  452.                                    'String',str_edi_length,           ...
  453.                                    'Backgroundcolor',Def_FraBkColor,  ...
  454.                                    'Enable','Inactive'                ...
  455.                                    );
  456.         txt_nextpow2_H = uicontrol(                                   ...
  457.                                    comTxtProp{:},                     ...
  458.                                    'Position',pos_txt_nextpow2_H,     ...
  459.                                    'String',str_txt_nextpow2          ...
  460.                                    );
  461.         edi_nextpow2_H = uicontrol(                                   ...
  462.                                    comEdiProp{:},                     ...
  463.                                    'Position',pos_edi_nextpow2_H,     ...
  464.                                    'String',str_edi_nextpow2,         ...
  465.                                    'Backgroundcolor',Def_FraBkColor,  ...
  466.                                    'Enable','Inactive'                ...
  467.                                    );
  468.         txt_prevpow2_H = uicontrol(                                   ...
  469.                                    comTxtProp{:},                     ...
  470.                                    'Position',pos_txt_prevpow2_H,     ...
  471.                                    'String',str_txt_prevpow2          ...
  472.                                    );
  473.         edi_prevpow2_H = uicontrol(                                   ...
  474.                                    comEdiProp{:},                     ...
  475.                                    'Position',pos_edi_prevpow2_H,     ...
  476.                                    'String',str_edi_prevpow2,         ...
  477.                                    'Backgroundcolor',Def_FraBkColor,  ...
  478.                                    'Enable','Inactive'                ...
  479.                                    );
  480.         txt_deslen_H   = uicontrol(                                   ...
  481.                                    comTxtProp{:},                     ...
  482.                                    'Position',pos_txt_deslen_H,       ...
  483.                                    'String',str_txt_deslen            ...
  484.                                    );
  485.         edi_deslen_H   = uicontrol(                                   ...
  486.                                    comEdiProp{:},                     ...
  487.                                    'Position',pos_edi_deslen_H,       ...
  488.                                    'String',str_edi_deslen,           ...
  489.                                    'Backgroundcolor',Def_EdiBkColor   ...
  490.                                    );
  491.         txt_direct_H   = uicontrol(                                   ...
  492.                                    comTxtProp{:},                     ...
  493.                                    'Position',pos_txt_direct_H,       ...
  494.                                    'String',str_txt_direct            ...
  495.                                    );
  496.         pop_direct_H   = uicontrol(                                   ...
  497.                                    comPopProp{:},                     ...
  498.                                    'Position',pos_pop_direct_H,       ...
  499.                                    'String',str_pop_direct_H          ...
  500.                                    );
  501.         frm_fra_V      = uicontrol(                                   ...
  502.                                    comFraProp{:},                     ...
  503.                                    'Position',pos_fra_V               ...
  504.                                    );
  505.         txt_fra_V      = uicontrol(                                   ...
  506.                                    comTxtProp{:},                     ...
  507.                                    'HorizontalAlignment','center',    ...
  508.                                    'Position',pos_txt_fra_V,          ...
  509.                                    'String',str_txt_fra_V             ...
  510.                                    );
  511.         txt_length_V   = uicontrol(                                   ...
  512.                                    comTxtProp{:},                     ...
  513.                                    'Position',pos_txt_length_V,       ...
  514.                                    'String',str_txt_length            ...
  515.                                    );
  516.         edi_length_V   = uicontrol(                                   ...
  517.                                    comEdiProp{:},                     ...
  518.                                    'Position',pos_edi_length_V,       ...
  519.                                    'String',str_edi_length,           ...
  520.                                    'Backgroundcolor',Def_FraBkColor,  ...
  521.                                    'Enable','Inactive'                ...
  522.                                    );
  523.  
  524.         txt_nextpow2_V = uicontrol(                                   ...
  525.                                    comTxtProp{:},                     ...
  526.                                    'Position',pos_txt_nextpow2_V,     ...
  527.                                    'String',str_txt_nextpow2          ...
  528.                                    );
  529.         edi_nextpow2_V = uicontrol(                                   ...
  530.                                    comEdiProp{:},                     ...
  531.                                    'Position',pos_edi_nextpow2_V,     ...
  532.                                    'String',str_edi_nextpow2,         ...
  533.                                    'Backgroundcolor',Def_FraBkColor,  ...
  534.                                    'Enable','Inactive'                ...
  535.                                    );
  536.         txt_prevpow2_V = uicontrol(                                   ...
  537.                                    comTxtProp{:},                     ...
  538.                                    'Position',pos_txt_prevpow2_V,     ...
  539.                                    'String',str_txt_prevpow2          ...
  540.                                    );
  541.         edi_prevpow2_V = uicontrol(                                   ...
  542.                                    comEdiProp{:},                     ...
  543.                                    'Position',pos_edi_prevpow2_V,     ...
  544.                                    'String',str_edi_prevpow2,         ...
  545.                                    'Backgroundcolor',Def_FraBkColor,  ...
  546.                                    'Enable','Inactive'                ...
  547.                                 );
  548.         txt_deslen_V   = uicontrol(                                   ...
  549.                                    comTxtProp{:},                     ...
  550.                                    'Position',pos_txt_deslen_V,       ...
  551.                                    'String',str_txt_deslen            ...
  552.                                    );
  553.         edi_deslen_V   = uicontrol(                                   ...
  554.                                    comEdiProp{:},                     ...
  555.                                    'Position',pos_edi_deslen_V,       ...
  556.                                    'String',str_edi_deslen,           ...
  557.                                    'Backgroundcolor',Def_EdiBkColor   ...
  558.                                    );
  559.         txt_direct_V   = uicontrol(                                   ...
  560.                                    comTxtProp{:},                     ...
  561.                                    'Position',pos_txt_direct_V,       ...
  562.                                    'String',str_txt_direct            ...
  563.                                    );
  564.         pop_direct_V   = uicontrol(                                   ...
  565.                                    comPopProp{:},                     ...
  566.                                    'Position',pos_pop_direct_V,       ...
  567.                                    'String',str_pop_direct_V          ...
  568.                                    );
  569.         txt_mode       = uicontrol(                                   ...
  570.                                    comTxtProp{:},                     ...
  571.                                    'Position',pos_txt_mode,           ...
  572.                                    'String',str_txt_mode              ...
  573.                                    );
  574.         pop_mode       = uicontrol(                                   ...
  575.                                    comPopProp{:},                     ...
  576.                                    'Position',pos_pop_mode,           ...
  577.                                    'String',str_pop_mode              ...
  578.                                    );
  579.         pus_extend     = uicontrol(                                   ...
  580.                                    comPusProp{:},                     ...
  581.                                    'Position',pos_pus_extend,         ...
  582.                                    'String',xlate(str_pus_extend),           ...
  583.                                    'Interruptible','On'               ...
  584.                                    );
  585.         txt_swtdec     = uicontrol(                                   ...
  586.                                    comTxtProp{:},                     ...
  587.                                    'Position',pos_txt_swtdec,         ...
  588.                                    'String',str_txt_swtdec            ...
  589.                                    );
  590.         pop_swtdec     = uicontrol(                                   ...
  591.                                    comPopProp{:},                     ...
  592.                                    'Position',pos_pop_swtdec,         ...
  593.                                    'String',str_pop_swtdec            ...
  594.                                    );
  595.         frm_fra_H_2    = uicontrol(                                   ...
  596.                                    comFraProp{:},                     ...
  597.                                    'Position',pos_fra_H_2             ...
  598.                                    );
  599.         txt_fra_H_2    = uicontrol(                                   ...
  600.                                    comTxtProp{:},                     ...
  601.                                    'HorizontalAlignment','center',    ...
  602.                                    'Position',pos_txt_fra_H_2,        ...
  603.                                    'String',str_txt_fra_H_2           ...
  604.                                    );
  605.         txt_swtlen_H   = uicontrol(                                   ...
  606.                                    comTxtProp{:},                     ...
  607.                                    'Position',pos_txt_swtlen_H,       ...
  608.                                    'String',str_txt_swtlen_H          ...
  609.                                    );
  610.         edi_swtlen_H   = uicontrol(                                   ...
  611.                                    comEdiProp{:},                     ...
  612.                                    'Position',pos_edi_swtlen_H,       ...
  613.                                    'String',str_edi_swtlen_H,         ...
  614.                                    'Backgroundcolor',Def_FraBkColor,  ...
  615.                                    'Enable','Inactive'                ...
  616.                                    );
  617.         txt_swtclen_H  = uicontrol(                                   ...
  618.                                    comTxtProp{:},                     ...
  619.                                    'Position',pos_txt_swtclen_H,      ...
  620.                                    'ToolTipString',str_tip_swtclen_H, ...
  621.                                    'String',str_txt_swtclen_H         ...
  622.                                    );
  623.         edi_swtclen_H  = uicontrol(                                   ...
  624.                                    comEdiProp{:},                     ...
  625.                                    'Position',pos_edi_swtclen_H,      ...
  626.                                    'String',str_edi_swtclen_H,        ...
  627.                                    'Backgroundcolor',Def_FraBkColor,  ...
  628.                                    'Enable','Inactive'                ...
  629.                                    );
  630.         txt_swtdir_H   = uicontrol(                                   ...
  631.                                    comTxtProp{:},                     ...
  632.                                    'Position',pos_txt_swtdir_H,       ...
  633.                                    'String',str_txt_swtdir_H          ...
  634.                                    );
  635.         edi_swtdir_H   = uicontrol(                                   ...
  636.                                    comEdiProp{:},                     ...
  637.                                    'Position',pos_edi_swtdir_H,       ...
  638.                                    'String',str_edi_swtdir_H,         ...
  639.                                    'Backgroundcolor',Def_FraBkColor,  ...
  640.                                    'Enable','Inactive'                ...
  641.                                    );
  642.         frm_fra_V_2    = uicontrol(                                   ...
  643.                                    comFraProp{:},                     ...
  644.                                    'Position',pos_fra_V_2             ...
  645.                                    );
  646.         txt_fra_V_2    = uicontrol(                                   ...
  647.                                    comTxtProp{:},                     ...
  648.                                    'HorizontalAlignment','center',    ...
  649.                                    'Position',pos_txt_fra_V_2,        ...
  650.                                    'String',str_txt_fra_V_2           ...
  651.                                    );
  652.         txt_swtlen_V   = uicontrol(                                   ...
  653.                                    comTxtProp{:},                     ...
  654.                                    'Position',pos_txt_swtlen_V,       ...
  655.                                    'String',str_txt_swtlen_V          ...
  656.                                    );
  657.         edi_swtlen_V   = uicontrol(                                   ...
  658.                                    comEdiProp{:},                     ...
  659.                                    'Position',pos_edi_swtlen_V,       ...
  660.                                    'String',str_edi_swtlen_V,         ...
  661.                                    'Backgroundcolor',Def_FraBkColor,  ...
  662.                                    'Enable','Inactive'                ...
  663.                                    );
  664.         txt_swtclen_V  = uicontrol(                                   ...
  665.                                    comTxtProp{:},                     ...
  666.                                    'Position',pos_txt_swtclen_V,      ...
  667.                                    'ToolTipString',str_tip_swtclen_V, ...
  668.                                    'String',str_txt_swtclen_V         ...
  669.                                    );
  670.         edi_swtclen_V  = uicontrol(                                   ...
  671.                                    comEdiProp{:},                     ...
  672.                                    'Position',pos_edi_swtclen_V,      ...
  673.                                    'String',str_edi_swtclen_V,        ...
  674.                                    'Backgroundcolor',Def_FraBkColor,  ...
  675.                                    'Enable','Inactive'                ...
  676.                                    );
  677.         txt_swtdir_V   = uicontrol(                                   ...
  678.                                    comTxtProp{:},                     ...
  679.                                    'Position',pos_txt_swtdir_V,       ...
  680.                                    'String',str_txt_swtdir_V          ...
  681.                                    );
  682.         edi_swtdir_V   = uicontrol(                                   ...
  683.                                    comEdiProp{:},                     ...
  684.                                    'Position',pos_edi_swtdir_V,       ...
  685.                                    'String',str_edi_swtdir_V,         ...
  686.                                    'Backgroundcolor',Def_FraBkColor,  ...
  687.                                    'Enable','Inactive'                ...
  688.                                    );
  689.                              
  690.         % Callback property of objects.
  691.         %------------------------------
  692.         str_win_imgxtool = num2mstr(win_imgxtool);
  693.         str_edi_deslen_H = num2mstr(edi_deslen_H);
  694.         str_pop_direct_H = num2mstr(pop_direct_H);
  695.         str_edi_deslen_V = num2mstr(edi_deslen_V);
  696.         str_pop_direct_V = num2mstr(pop_direct_V);
  697.         str_pop_mode   = num2mstr(pop_mode);
  698.         str_pus_extend   = num2mstr(pus_extend);
  699.         cba_edi_deslen_H = [mfilename '(''update_deslen'','   ...
  700.                                  str_win_imgxtool             ...
  701.                                  ',''H'');'];
  702.         cba_edi_deslen_V = [mfilename '(''update_deslen'','   ...
  703.                                  str_win_imgxtool             ...
  704.                                  ',''V'');'];
  705.         cba_pop_direct_H = [mfilename '(''clear_GRAPHICS'','  ...
  706.                                  str_win_imgxtool             ...
  707.                                  ');'];
  708.         cba_pop_direct_V = [mfilename '(''clear_GRAPHICS'','  ...
  709.                                  str_win_imgxtool             ...
  710.                                  ');'];
  711.         cba_pop_mode   = [mfilename '(''mode'','            ...
  712.                                  str_win_imgxtool             ...
  713.                                  ');'];
  714.         cba_pus_extend   = [mfilename '(''extend_truncate'',' ...
  715.                                  str_win_imgxtool             ...
  716.                                  ');'];
  717.         cba_pop_swtdec   = [mfilename '(''update_swtdec'','   ...
  718.                                  str_win_imgxtool             ...
  719.                                  ');'];
  720.         set(edi_deslen_H,'Callback',cba_edi_deslen_H);
  721.         set(pop_direct_H,'Callback',cba_pop_direct_H);
  722.         set(edi_deslen_V,'Callback',cba_edi_deslen_V);
  723.         set(pop_direct_V,'Callback',cba_pop_direct_V);
  724.         set(pop_mode,'Callback',cba_pop_mode);
  725.         set(pus_extend,'Callback',cba_pus_extend);
  726.         set(pop_swtdec,'Callback',cba_pop_swtdec);
  727.         
  728.         % Graphic part of the window.
  729.         %============================
  730.         % Axes Construction.
  731.         %-------------------
  732.         commonProp  = {...
  733.                        'Parent',win_imgxtool,           ...
  734.                        'Visible','off',                 ...
  735.                        'Units','pixels',                ...
  736.                        'XTicklabelMode','manual',       ...
  737.                        'YTicklabelMode','manual',       ...
  738.                        'XTicklabel',[],'YTicklabel',[], ...
  739.                        'XTick',[],'YTick',[],           ...
  740.                        'Box','On'                       ...
  741.                        };
  742.         % Image Axes construction.
  743.         %--------------------------
  744.         x_left      = x_graph;
  745.         x_wide      = w_graph-2*x_left;
  746.         y_low       = y_graph+2*bdy;
  747.         y_height    = h_graph-y_low-2*bdy;
  748.         Pos_Axe_Img = [x_left, y_low, x_wide, y_height];
  749.         Axe_Img     = axes( commonProp{:},         ...
  750.                             'Ydir','Reverse',      ...
  751.                             'Position',Pos_Axe_Img ...
  752.                             );
  753.         % Legend Axes construction.
  754.         %--------------------------
  755.         X_Leg = Pos_Axe_Img(1);
  756.         Y_Leg = Pos_Axe_Img(2) + 11*Pos_Axe_Img(4)/10;
  757.         W_Leg = (Pos_Axe_Img(3) - Pos_Axe_Img(1)) / 2.5;
  758.         H_Leg = (Pos_Axe_Img(4) - Pos_Axe_Img(2)) / 4;
  759.         Pos_Axe_Leg = [X_Leg Y_Leg W_Leg H_Leg];
  760.         ud.dynvzaxe.enable = 'Off';
  761.         Axe_Leg = axes(commonProp{:},          ...
  762.                        'Position',Pos_Axe_Leg, ...
  763.                        'Xlim',[0 180],         ...
  764.                        'Ylim',[0 20],          ...
  765.                        'Drawmode','fast',      ...
  766.                        'userdata',ud           ...
  767.                        );
  768.         L1 = line(                           ...
  769.                   'Parent',Axe_Leg,          ...
  770.                   'Xdata',11:30,             ...
  771.                   'Ydata',ones(1,20)*14,     ...
  772.                   'LineWidth',3,             ...
  773.                   'Visible','off',           ...
  774.                   'Color','yellow'           ...
  775.                   );
  776.         L2 = line(                           ...
  777.                   'Parent',Axe_Leg,          ...
  778.                   'Xdata',11:30,             ...
  779.                   'Ydata',ones(1,20)*7,      ...
  780.                   'LineWidth',3,             ...
  781.                   'Visible','off',           ...
  782.                   'Color','red'              ...
  783.                   );
  784.         T1 = text(40,14,xlate('Transformed image'), ...
  785.                   'Parent',Axe_Leg,          ...
  786.                   'FontWeight','bold',       ...
  787.                   'Visible','off'            ...
  788.                   );
  789.         T2 = text(40,7,xlate('Original image'),     ...
  790.                   'Parent',Axe_Leg,          ...
  791.                   'FontWeight','bold',       ...
  792.                   'Visible','off'            ...
  793.                   );
  794.         % Adding colormap GUI.
  795.         %---------------------
  796.         [Hdls_Colmap1,Hdls_Colmap2] = utcolmap('create',win_imgxtool, ...
  797.                  'xloc',xlocINI,'bkcolor',Def_FraBkColor);
  798.         Hdls_Colmap = [Hdls_Colmap1 Hdls_Colmap2];
  799.         set(Hdls_Colmap,'visible','off');
  800.         % Setting units to normalized.
  801.         %-----------------------------
  802.         wfigmngr('normalize',win_imgxtool);
  803.         % Store values.
  804.         %--------------
  805.         Hdls_UIC_C  = {...
  806.                        m_load,m_save,m_demo,...
  807.                        txt_image,edi_image,  ...
  808.                        txt_mode,pop_mode,pus_extend ...
  809.                        };
  810.         Hdls_UIC_H  = {...
  811.                        frm_fra_H,txt_fra_H,           ...
  812.                        txt_length_H,edi_length_H,     ...
  813.                        txt_nextpow2_H,edi_nextpow2_H, ...
  814.                        txt_prevpow2_H,edi_prevpow2_H, ...
  815.                        txt_deslen_H,edi_deslen_H,     ...
  816.                        txt_direct_H,pop_direct_H      ...
  817.                        };
  818.         Hdls_UIC_V  = {...
  819.                        frm_fra_V,txt_fra_V,           ...
  820.                        txt_length_V,edi_length_V,     ...
  821.                        txt_nextpow2_V,edi_nextpow2_V, ...
  822.                        txt_prevpow2_V,edi_prevpow2_V, ...
  823.                        txt_deslen_V,edi_deslen_V,     ...
  824.                        txt_direct_V,pop_direct_V      ...
  825.                        };
  826.         Hdls_UIC_Swt = {...
  827.                        txt_swtdec,pop_swtdec,       ...
  828.                        frm_fra_H_2,txt_fra_H_2,     ...
  829.                        txt_swtlen_H,edi_swtlen_H,   ...
  830.                        txt_swtclen_H,edi_swtclen_H, ...
  831.                        txt_swtdir_H,edi_swtdir_H,   ...
  832.                        txt_swtdec,pop_swtdec,       ...
  833.                        frm_fra_V_2,txt_fra_V_2,     ...
  834.                        txt_swtlen_V,edi_swtlen_V,   ...
  835.                        txt_swtclen_V,edi_swtclen_V, ...
  836.                        txt_swtdir_V,edi_swtdir_V    ...
  837.                        };
  838.  
  839.         Hdls_Axes    = struct('Axe_Img',Axe_Img,'Axe_Leg',Axe_Leg);
  840.         Pos_Axe_Img_Ori = get(Axe_Img,'Position');
  841. % Add Context Sensitive Help (CSHelp).
  842. %-------------------------------------
  843. hdl_BORDER_DIST = [txt_mode,pop_mode];
  844. wfighelp('add_ContextMenu',win_imgxtool,...
  845. hdl_BORDER_DIST,'BORDER_DIST');
  846. %-------------------------------------
  847.         
  848. % Store handles and values.
  849.         %--------------------------
  850.         wfigmngr('storeValue',win_imgxtool,'Hdls_UIC_C',Hdls_UIC_C);
  851.         wfigmngr('storeValue',win_imgxtool,'Hdls_UIC_H',Hdls_UIC_H);
  852.         wfigmngr('storeValue',win_imgxtool,'Hdls_UIC_V',Hdls_UIC_V);
  853.         wfigmngr('storeValue',win_imgxtool,'Hdls_UIC_Swt',Hdls_UIC_Swt);
  854.         wfigmngr('storeValue',win_imgxtool,'Hdls_Axes',Hdls_Axes);
  855.         wfigmngr('storeValue',win_imgxtool,'Hdls_Colmap',Hdls_Colmap);
  856.         wfigmngr('storeValue',win_imgxtool,'Pos_Axe_Img_Ori',Pos_Axe_Img_Ori);
  857.         % End waiting.
  858.         %---------------
  859.         wwaiting('off',win_imgxtool);
  860.     case 'load'
  861.     %------------------------------------------%
  862.     % Option: 'LOAD' - Load the original image %
  863.     %------------------------------------------%
  864.         % Loading file.
  865.         %--------------
  866.         if length(varargin)<2  % LOAD Option
  867.             imgFileType = ['*.mat;*.bmp;*.hdf;*.jpg;' ...
  868.                     '*.jpeg;*.pcx;*.tif;*.tiff;*.gif'];
  869.             [imgInfos,Anal_Image,map,ok] = ...
  870.                 utguidiv('load_img',win_imgxtool,imgFileType, ...
  871.                 'Load Image',default_nbcolors);
  872.         else
  873.             img_Name = deblank(varargin{2});
  874.             filename = [img_Name '.mat'];
  875.             pathname = utguidiv('WTB_DemoPath',filename);
  876.             [imgInfos,Anal_Image,map,ok] = ...
  877.                 utguidiv('load_dem2D',win_imgxtool,pathname,filename,default_nbcolors);
  878.         end
  879.         if ~ok, return; end
  880.         % Begin waiting.
  881.         %---------------
  882.         wwaiting('msg',win_imgxtool,'Wait ... loading');
  883.         % Cleaning.
  884.         %----------
  885.         imgxtool('clear_GRAPHICS',win_imgxtool,'load');
  886.         % Disable save menu.
  887.         %-------------------
  888.         set(m_save,'Enable','off');
  889.         % Compute UIC values.
  890.         %--------------------
  891.         H           = imgInfos.size(1);
  892.         V           = imgInfos.size(2);
  893.         pow_H       = fix(log(H)/log(2));
  894.         Next_Pow2_H = 2^(pow_H+1);
  895.         if isequal(2^pow_H,H)
  896.             Prev_Pow2_H = 2^(pow_H-1);
  897.             swtpow_H    = pow_H;
  898.         else
  899.             Prev_Pow2_H = 2^pow_H;
  900.             swtpow_H    = pow_H+1;
  901.         end
  902.         pow_V       = fix(log(V)/log(2));
  903.         Next_Pow2_V = 2^(pow_V+1);
  904.         if isequal(2^pow_V,V)
  905.             Prev_Pow2_V   = 2^(pow_V-1);
  906.             swtpow_V    = pow_V;
  907.         else
  908.             Prev_Pow2_V   = 2^pow_V;
  909.             swtpow_V    = pow_V+1;
  910.         end
  911.         
  912.         % Compute the max level value for SWT.
  913.         %-------------------------------------
  914.         Max_Lev = min(swtpow_H,swtpow_V);
  915.                 
  916.         % Compute the default level for SWT .
  917.         %-----------------------------------
  918.         def_pow = 1;
  919.         if ~rem(H,2)
  920.             while ~rem(H,2^def_pow), def_pow = def_pow + 1; end
  921.             def_level_H = def_pow-1;
  922.         else
  923.             def_level_H = def_pow;
  924.         end
  925.         
  926.         def_pow = 1;
  927.         if ~rem(V,2)
  928.             while ~rem(V,2^def_pow), def_pow = def_pow + 1; end
  929.             def_level_V = def_pow-1;
  930.         else
  931.             def_level_V = def_pow;
  932.         end
  933.         Def_Lev = min(max(def_level_H,def_level_V),Max_Lev);
  934.         
  935.         % Compute the extended lengths for SWT.
  936.         %--------------------------------------
  937.         C_Length_H = H;
  938.         while rem(C_Length_H,2^def_level_H), C_Length_H = C_Length_H + 1; end
  939.         C_Length_V = V;
  940.         while rem(C_Length_V,2^def_level_V), C_Length_V = C_Length_V + 1; end
  941.         
  942.         % Set UIC values.
  943.         %----------------
  944.         set(edi_image,'String',imgInfos.name);
  945.         set(edi_length_H,'String',sprintf('%.0f',H));
  946.         set(edi_nextpow2_H,'String',sprintf('%.0f',Next_Pow2_H));
  947.         set(edi_prevpow2_H,'String',sprintf('%.0f',Prev_Pow2_H));
  948.         set(edi_deslen_H,'String',sprintf('%.0f',Next_Pow2_H));
  949.         set(pop_direct_H,'Value',1);
  950.         set(edi_length_V,'String',sprintf('%.0f',V));
  951.         set(edi_nextpow2_V,'String',sprintf('%.0f',Next_Pow2_V));
  952.         set(edi_prevpow2_V,'String',sprintf('%.0f',Prev_Pow2_V));
  953.         set(edi_deslen_V,'String',sprintf('%.0f',Next_Pow2_V));
  954.         set(pop_direct_V,'Value',1);
  955.         set(pop_mode,'Value',1);
  956.         set(pus_extend,'String',xlate('Extend'));
  957.         set(pus_extend,'Enable','On');
  958.         set(pop_swtdec,'String',num2str((1:Max_Lev)'));
  959.         set(pop_swtdec,'Value',Def_Lev);
  960.         set(edi_swtlen_H,'String',sprintf('%.0f',H));
  961.         set(edi_swtlen_V,'String',sprintf('%.0f',V));        
  962.         set(edi_swtclen_H,'String',sprintf('%.0f',C_Length_H));
  963.         set(edi_swtclen_V,'String',sprintf('%.0f',C_Length_V));        
  964.                 
  965.         % Set UIC visible on.
  966.         %--------------------
  967.         set(cat(1,Hdls_UIC_H{:}),'visible','on')
  968.         set(cat(1,Hdls_UIC_V{:}),'visible','on')
  969.         set(cat(1,Hdls_UIC_Swt{:}),'visible','off')
  970.         set(cat(1,Hdls_UIC_C{4:end}),'visible','on')
  971.         % Setting Colormap.
  972.         %------------------
  973.         maxVal   = max(max(Anal_Image));
  974.         nbcolors = round(max([2,min([maxVal,default_nbcolors])]));
  975.         cbcolmap('set',win_imgxtool,'pal',{'pink',nbcolors});
  976.         set(Hdls_Colmap,'Visible','on');
  977.         set(Hdls_Colmap,'Enable','on');
  978.         % Get Axes Handles.
  979.         %------------------
  980.         Axe_Img =  Hdls_Axes.Axe_Img ;
  981.         % Drawing.
  982.         %---------
  983.         NB_ColorsInPal = default_nbcolors;
  984.         Anal_Image     = wimgcode('cod',0,Anal_Image,NB_ColorsInPal,codemat_v);
  985.         Img_Ori        = image(                ...
  986.                            'parent',Axe_Img,   ...
  987.                            'Xdata',[1,H],      ...
  988.                            'Ydata',[1,V],      ...
  989.                            'Cdata',Anal_Image, ...
  990.                            'Visible','on'      ...
  991.                            );
  992.         [w,h]          = wpropimg([H V],Pos_Axe_Img_Ori(3),Pos_Axe_Img_Ori(4));
  993.         Pos_Axe_Img    = Pos_Axe_Img_Ori;
  994.         Pos_Axe_Img(1) = Pos_Axe_Img(1)+abs(Pos_Axe_Img(3)-w)/2;
  995.         Pos_Axe_Img(2) = Pos_Axe_Img(2)+abs(Pos_Axe_Img(4)-h)/2;
  996.         Pos_Axe_Img(3) = w;
  997.         Pos_Axe_Img(4) = h;
  998.         set(Axe_Img,                ...
  999.             'Xlim',[1,H],           ...
  1000.             'Ylim',[1,V],           ...
  1001.             'Position',Pos_Axe_Img, ...
  1002.             'Visible','on');
  1003.         set(get(Axe_Img,'title'),'string',xlate('Original Image'));
  1004.         % Store values.
  1005.         %--------------
  1006.         wfigmngr('storeValue',win_imgxtool,'Anal_Image',Anal_Image);
  1007.         wfigmngr('storeValue',win_imgxtool,'Pos_Axe_Img_Bas',Pos_Axe_Img);
  1008.         % Update File_Save_Flag.
  1009.         %-----------------------
  1010.         File_Save_Flag = 0;
  1011.         wfigmngr('storeValue',win_imgxtool,'File_Save_Flag',File_Save_Flag);
  1012.         
  1013.         % Dynvtool Attachement.
  1014.         %----------------------
  1015.         dynvtool('init',win_imgxtool,[],Axe_Img,[],[1 1],'','','');
  1016.         % End waiting.
  1017.         %-------------
  1018.         wwaiting('off',win_imgxtool);
  1019.     case 'demo'
  1020.         imgxtool('load',varargin{:});
  1021.         Signal_Name  = deblank(varargin{2});
  1022.         ext_OR_trunc = varargin{3};
  1023.         if length(varargin)>3  & ~isempty(varargin{4})
  1024.             par_Demo = varargin{4};
  1025.         else
  1026.             return;
  1027.         end
  1028.         extMode  = par_Demo{1};
  1029.         lenSIG   = par_Demo{2};
  1030.         direct_H = lower(par_Demo{3});
  1031.         direct_V = lower(par_Demo{4});
  1032.         if ~isequal(extMode,'swt')
  1033.             set(edi_deslen_H,'String',sprintf('%.0f',lenSIG(1)));
  1034.             imgxtool('update_deslen',win_imgxtool,'H','noClear');
  1035.             set(edi_deslen_V,'String',sprintf('%.0f',lenSIG(2)));
  1036.             imgxtool('update_deslen',win_imgxtool,'V','noClear');
  1037.         else
  1038.             set(pop_swtdec,'Value',lenSIG)
  1039.             imgxtool('update_swtdec',win_imgxtool)
  1040.         end
  1041.         switch direct_H
  1042.           case 'both'  , direct = 1;
  1043.           case 'left'  , direct = 2;
  1044.           case 'right' , direct = 3;
  1045.         end
  1046.         set(pop_direct_H,'Value',direct);
  1047.         switch direct_V
  1048.           case 'both' , direct = 1;
  1049.           case 'up'   , direct = 2;
  1050.           case 'down' , direct = 3;
  1051.         end
  1052.         set(pop_direct_V,'Value',direct);
  1053.         switch ext_OR_trunc
  1054.           case 'ext'
  1055.             switch extMode
  1056.               case 'sym' ,         extVal = 1;
  1057.               case 'ppd' ,         extVal = 5;
  1058.               case 'zpd' ,         extVal = 6;
  1059.               case 'sp0' ,         extVal = 7;
  1060.               case {'sp1','spd'} , extVal = 8;
  1061.               case 'swt' ,         extVal = 9;
  1062.             end
  1063.             set(pop_mode,'Value',extVal);
  1064.             imgxtool('mode',win_imgxtool,'noClear')
  1065.           case 'trunc'
  1066.         end
  1067.         imgxtool('extend_truncate',win_imgxtool);
  1068.     case 'update_swtdec'
  1069.     %----------------------------------------------------------------------%
  1070.     % Option: 'UPDATE_SWTDEC' - Update values when using popup in SWT case %
  1071.     %----------------------------------------------------------------------%        
  1072.         % Update the computed length.
  1073.         %----------------------------
  1074.         Image_Length_H = wstr2num(get(edi_swtlen_H,'String'));
  1075.         Image_Length_V = wstr2num(get(edi_swtlen_V,'String'));
  1076.         Level          = get(pop_swtdec,'Value');
  1077.         remLen_H       = rem(Image_Length_H,2^Level);
  1078.         remLen_V       = rem(Image_Length_V,2^Level);
  1079.         if remLen_H>0
  1080.             C_Length_H = Image_Length_H + 2^Level-remLen_H;
  1081.         else
  1082.             C_Length_H = Image_Length_H;
  1083.         end
  1084.         if remLen_V>0
  1085.             C_Length_V = Image_Length_V + 2^Level-remLen_V;
  1086.         else
  1087.             C_Length_V = Image_Length_V;
  1088.         end
  1089.         set(edi_swtclen_H,'String',sprintf('%.0f',C_Length_H));
  1090.         set(edi_swtclen_V,'String',sprintf('%.0f',C_Length_V));
  1091.         
  1092.         % Enabling Extend button.
  1093.         %------------------------        
  1094.         set(pus_extend,'String',xlate('Extend'),'Enable','on');
  1095.     case 'update_deslen'
  1096.     %--------------------------------------------------------------------------%
  1097.     % Option: 'UPDATE_DESLEN' - Update values when changing the Desired Length %
  1098.     %--------------------------------------------------------------------------%
  1099.         % Get arguments.
  1100.         %---------------
  1101.         Direction = varargin{2};
  1102.         % Cleaning.
  1103.         %----------
  1104.         if nargin<4 , imgxtool('clear_GRAPHICS',win_imgxtool); end
  1105.         % Get Common UIC Handles.
  1106.         %------------------------
  1107.         Image_length_H   = wstr2num(get(edi_length_H,'String'));
  1108.         Desired_length_H = wstr2num(get(edi_deslen_H,'String'));
  1109.         Image_length_V   = wstr2num(get(edi_length_V,'String'));
  1110.         Desired_length_V = wstr2num(get(edi_deslen_V,'String'));
  1111.         uic_mode         = [txt_mode;pop_mode];
  1112.         switch Direction
  1113.           case 'H'
  1114.             % Update UIC values.
  1115.             %-------------------
  1116.             if      isempty(Desired_length_H) | Desired_length_H < 2
  1117.                     set(edi_deslen_H,'String',get(edi_nextpow2_H,'String'));
  1118.                     set(txt_direct_H,'String','Direction to extend');
  1119.                     set(pus_extend,'String',xlate('Extend'),'Enable','on');
  1120.             elseif  Image_length_H <= Desired_length_H
  1121.                     set(txt_direct_H,'String','Direction to extend');
  1122.                     set(pus_extend,'String',xlate('Extend'));
  1123.             elseif  Image_length_H > Desired_length_H
  1124.                     set(txt_direct_H,'String','Direction to truncate');
  1125.                     set(pus_extend,'String',xlate('Truncate'));
  1126.             end
  1127.           case 'V'
  1128.             % Update UIC values.
  1129.             %-------------------
  1130.             if      isempty(Desired_length_V) | Desired_length_V < 2
  1131.                     set(edi_deslen_V,'String',get(edi_nextpow2_V,'String'));
  1132.                     set(txt_direct_V,'String','Direction to extend');
  1133.                     set(pus_extend,'String',xlate('Extend'));
  1134.             elseif  Image_length_V <= Desired_length_V
  1135.                     set(txt_direct_V,'String','Direction to extend');
  1136.                     set(pus_extend,'String',xlate('Extend'));
  1137.             elseif  Image_length_V > Desired_length_V
  1138.                     set(txt_direct_V,'String','Direction to truncate');
  1139.                     set(pus_extend,'String',xlate('Truncate'));
  1140.             end
  1141.           otherwise
  1142.             errargt(mfilename,'Unknown Action','msg');
  1143.             error('*');
  1144.         end
  1145.         set(uic_mode,'Enable','on');
  1146.         set(pus_extend,'Enable','on');                                
  1147.         if      isequal(Image_length_H,Desired_length_H) & ...
  1148.                 isequal(Image_length_V,Desired_length_V)
  1149.                 set(txt_direct_V,'String','Direction to extend');
  1150.                 set(txt_direct_H,'String','Direction to extend');
  1151.                 set(uic_mode,'Enable','off');
  1152.                 set(pus_extend,'Enable','off');                        
  1153.         elseif  ((Image_length_H <= Desired_length_H)  & ...
  1154.                  (Image_length_V <  Desired_length_V)) | ...
  1155.                 ((Image_length_H <  Desired_length_H)  & ...
  1156.                  (Image_length_V <= Desired_length_V))                
  1157.                 set(uic_mode,'Visible','on');
  1158.                 set(pus_extend,'String',xlate('Extend'));
  1159.         elseif  (Image_length_H <= Desired_length_H) & ...
  1160.                 (Image_length_V > Desired_length_V)
  1161.                 set(uic_mode,'Visible','on');
  1162.                 set(pus_extend,'String',xlate('Extend / Truncate'));
  1163.         elseif  (Image_length_H > Desired_length_H) & ...
  1164.                 (Image_length_V <= Desired_length_V)
  1165.                 set(uic_mode,'Visible','on');
  1166.                 set(pus_extend,'String',xlate('Truncate / Extend'));
  1167.         elseif  (Image_length_H > Desired_length_H) & ...
  1168.                 (Image_length_V > Desired_length_V)
  1169.                 set(uic_mode,'Visible','off');
  1170.                 set(pus_extend,'String',xlate('Truncate'));
  1171.         end
  1172.         set(pus_extend,'Visible','on');
  1173.     case 'mode'
  1174.     %------------------------------------------------------------------------%
  1175.     % Option: 'MODE' -  Update the command part when changing Extension Mode %
  1176.     %------------------------------------------------------------------------%
  1177.         % Cleaning.
  1178.         %----------
  1179.         if nargin<3 , imgxtool('clear_GRAPHICS',win_imgxtool); end
  1180.         % Checking the SWT case for visibility setings.
  1181.         %----------------------------------------------
  1182.         Mode_str = get(pop_mode,'String');
  1183.         Mode_val = get(pop_mode,'Value');
  1184.         if  strcmp(deblank(Mode_str(Mode_val,:)),'For SWT')
  1185.             set(cat(1,Hdls_UIC_H{:}),'visible','off')
  1186.             set(cat(1,Hdls_UIC_V{:}),'visible','off')
  1187.             set(cat(1,Hdls_UIC_Swt{:}),'visible','on')
  1188.             Image_Length_H    = wstr2num(get(edi_swtlen_H,'String'));
  1189.             Computed_Length_H = wstr2num(get(edi_swtclen_H,'String'));
  1190.             Image_Length_V    = wstr2num(get(edi_swtlen_V,'String'));
  1191.             Computed_Length_V = wstr2num(get(edi_swtclen_V,'String'));
  1192.             set(pus_extend,'String',xlate('Extend'));
  1193.             if isequal(Image_Length_H,nextpow2(Image_Length_H)) & ...
  1194.                 isequal(Image_Length_V,nextpow2(Image_Length_V))
  1195.                 set(pus_extend,'Enable','off');
  1196.                 strSize = ['(' int2str(Image_Length_V), 'x', ...
  1197.                                int2str(Image_Length_H) ')'];
  1198.                 msg = strvcat(...
  1199.                   sprintf('The size of the image %s is a power of 2.', strSize),  ...
  1200.                   ['The SWT extension is not necessary!']);
  1201.                 wwarndlg(msg,'SWT Extension Mode','block');
  1202.             elseif Image_Length_H < Computed_Length_H | ...
  1203.                 Image_Length_V < Computed_Length_V
  1204.                 set(pus_extend,'Enable','on');
  1205.             end
  1206.         else
  1207.             set(pus_extend,'Enable','on');
  1208.             set(cat(1,Hdls_UIC_H{:}),'visible','on')
  1209.             set(cat(1,Hdls_UIC_V{:}),'visible','on')
  1210.             set(cat(1,Hdls_UIC_Swt{:}),'visible','off')
  1211.         end
  1212.         set(cat(1,Hdls_UIC_C{4:end}),'visible','on');
  1213.             
  1214.     case 'extend_truncate'
  1215.     %-------------------------------------------------------------------------%
  1216.     % Option: 'EXTEND_TRUNCATE' - Compute the new Extended or Truncated image %
  1217.     %-------------------------------------------------------------------------%
  1218.         
  1219.         % Begin waiting.
  1220.         %---------------
  1221.         wwaiting('msg',win_imgxtool,'Wait ... computing');
  1222.         % Get Axes Handles.
  1223.         %------------------
  1224.         Axe_Img =  Hdls_Axes.Axe_Img;
  1225.         % Get stored structure.
  1226.         %----------------------        
  1227.         Anal_Image = wfigmngr('getValue',win_imgxtool,'Anal_Image');
  1228.         % Get UIC values.
  1229.         %----------------
  1230.         Image_length_H   = wstr2num(get(edi_length_H,'String'));
  1231.         Str_pop_direct_H = get(pop_direct_H,'String');
  1232.         Val_pop_direct_H = get(pop_direct_H,'Value');
  1233.         Str_pop_direct_H = deblank(Str_pop_direct_H(Val_pop_direct_H,:));
  1234.         Image_length_V   = wstr2num(get(edi_length_V,'String'));
  1235.         Str_pop_direct_V = get(pop_direct_V,'String');
  1236.         Val_pop_direct_V = get(pop_direct_V,'Value');
  1237.         Str_pop_direct_V = deblank(Str_pop_direct_V(Val_pop_direct_V,:));
  1238.         Str_pop_mode     = get(pop_mode,'String');
  1239.         Val_pop_mode     = get(pop_mode,'Value');
  1240.         Str_pop_mode     = deblank(Str_pop_mode(Val_pop_mode,:));
  1241.         % Directions mode conversion and desired lengths.
  1242.         %------------------------------------------------
  1243.         if strcmp(Str_pop_mode,'For SWT')
  1244.             Dir_H = 'r';
  1245.             Dir_V = 'b';
  1246.             Desired_length_H = wstr2num(get(edi_swtclen_H,'String'));
  1247.             Desired_length_V = wstr2num(get(edi_swtclen_V,'String'));
  1248.         else
  1249.             Dir_H_Values     = ['b';'l';'r'];
  1250.             Dir_V_Values     = ['b';'u';'d'];
  1251.             Dir_H            = Dir_H_Values(Val_pop_direct_H);
  1252.             Dir_V            = Dir_V_Values(Val_pop_direct_V);
  1253.             Desired_length_H = wstr2num(get(edi_deslen_H,'String'));
  1254.             Desired_length_V = wstr2num(get(edi_deslen_V,'String'));
  1255.         end
  1256.         Desired_Size = [Desired_length_V Desired_length_H];
  1257.         % Extension mode conversion.
  1258.         %---------------------------
  1259.         Mode_Values = {'sym';'symw';'asym';'asymw';'ppd';'zpd';'sp0';'spd';'ppd'};
  1260.         Mode        = Mode_Values{Val_pop_mode};
  1261.         % Get action to do.
  1262.         %------------------
  1263.         action = deblank(get(pus_extend,'string'));
  1264.         switch action
  1265.           case xlate('Truncate')
  1266.               Deb_O_H = 1;
  1267.               Deb_O_V = 1;
  1268.               delta_H = Image_length_H - Desired_length_H;
  1269.               delta_V = Image_length_V - Desired_length_V;
  1270.               switch Str_pop_direct_H
  1271.                 case 'Left'  , Deb_N_H = 1 + delta_H;
  1272.                 case 'Right' , Deb_N_H = 1;
  1273.                 case 'Both'  , Deb_N_H = 1 + fix(delta_H/2);
  1274.               end
  1275.               switch Str_pop_direct_V
  1276.                 case 'Up'   , Deb_N_V = 1 + delta_V;
  1277.                 case 'Down' , Deb_N_V = 1;
  1278.                 case 'Both' , Deb_N_V = 1 + fix(delta_V/2);
  1279.               end
  1280.               Fin_O_H      = Deb_O_H + Image_length_H - 1;
  1281.               Fin_O_V      = Deb_O_V + Image_length_V - 1;
  1282.               Fin_N_H      = Deb_N_H + Desired_length_H - 1;
  1283.               Fin_N_V      = Deb_N_V + Desired_length_V - 1;
  1284.               First_Point  = [Deb_N_V Deb_N_H ];
  1285.               Image_Lims_O = [Deb_O_H Fin_O_H Deb_O_V Fin_O_V];
  1286.               Image_Lims_N = [Deb_N_H Fin_N_H Deb_N_V Fin_N_V];
  1287.               New_Image    = wkeep2(Anal_Image,Desired_Size,First_Point);
  1288.               imgxtool('draw',win_imgxtool,Anal_Image,New_Image, ...
  1289.                           [Image_Lims_O;Image_Lims_N]);
  1290.           case xlate('Extend / Truncate')
  1291.               Deb_O_V = 1;
  1292.               Deb_N_H = 1;
  1293.               delta_H = Desired_length_H - Image_length_H;
  1294.               delta_V = Image_length_V - Desired_length_V;
  1295.               switch Str_pop_direct_H
  1296.                 case 'Left'  , Deb_O_H = 1 + delta_H;
  1297.                 case 'Right' , Deb_O_H = 1;
  1298.                 case 'Both'  , Deb_O_H = 1 + fix(delta_H/2);
  1299.               end
  1300.               switch Str_pop_direct_V
  1301.                 case 'Up'   , Deb_N_V = 1 + delta_V;
  1302.                 case 'Down' , Deb_N_V = 1;
  1303.                 case 'Both' , Deb_N_V = 1 + fix(delta_V/2);
  1304.               end
  1305.               Fin_O_H      = Deb_O_H + Image_length_H - 1;
  1306.               Fin_O_V      = Deb_O_V + Image_length_V - 1;
  1307.               Fin_N_H      = Deb_N_H + Desired_length_H - 1;
  1308.               Fin_N_V      = Deb_N_V + Desired_length_V - 1;
  1309.               First_Point  = [Deb_N_V Deb_N_H ];
  1310.               Image_Lims_O = [Deb_O_H Fin_O_H Deb_O_V Fin_O_V];
  1311.               Image_Lims_N = [Deb_N_H Fin_N_H Deb_N_V Fin_N_V];
  1312.               New_Image    = wkeep2(Anal_Image,Desired_Size,First_Point);
  1313.               switch Dir_H
  1314.                 case {'l','r'}
  1315.                   New_Image = wextend('ac',Mode,New_Image,delta_H,Dir_H);
  1316.                 case 'b'
  1317.                   Ext_Size  = ceil(delta_H/2);
  1318.                   New_Image = wextend('ac',Mode,New_Image,Ext_Size,Dir_H);
  1319.                   if rem(delta_H,2)
  1320.                       New_Image = wkeep2(New_Image,Desired_Size,'c','dr');
  1321.                   end
  1322.               end
  1323.               imgxtool('draw',win_imgxtool,Anal_Image,New_Image, ...
  1324.                           [Image_Lims_O;Image_Lims_N]);
  1325.           case xlate('Truncate / Extend')
  1326.               Deb_O_H = 1;
  1327.               Deb_N_V = 1;
  1328.               delta_H = Image_length_H - Desired_length_H;
  1329.               delta_V = Desired_length_V - Image_length_V ;
  1330.               switch Str_pop_direct_H
  1331.                 case 'Left'  , Deb_N_H = 1 + delta_H;
  1332.                 case 'Right' , Deb_N_H = 1;
  1333.                 case 'Both'  , Deb_N_H = 1 + fix(delta_H/2);
  1334.               end
  1335.               switch Str_pop_direct_V
  1336.                 case 'Up'   , Deb_O_V = 1 + delta_V;
  1337.                 case 'Down' , Deb_O_V = 1;
  1338.                 case 'Both' , Deb_O_V = 1 + fix(delta_V/2);
  1339.               end
  1340.               Fin_O_H      = Deb_O_H + Image_length_H - 1;
  1341.               Fin_O_V      = Deb_O_V + Image_length_V - 1;
  1342.               Fin_N_H      = Deb_N_H + Desired_length_H - 1;
  1343.               Fin_N_V      = Deb_N_V + Desired_length_V - 1;
  1344.               First_Point  = [Deb_N_V Deb_N_H ];
  1345.               Image_Lims_O = [Deb_O_H Fin_O_H Deb_O_V Fin_O_V];
  1346.               Image_Lims_N = [Deb_N_H Fin_N_H Deb_N_V Fin_N_V];
  1347.               New_Image    = wkeep2(Anal_Image,Desired_Size,First_Point);
  1348.               switch Dir_V
  1349.                 case {'u','d'}
  1350.                   New_Image = wextend('ar',Mode,New_Image,delta_V,Dir_V);
  1351.                 case 'b'
  1352.                   Ext_Size  = ceil(delta_V/2);
  1353.                   New_Image = wextend('ar',Mode,Anal_Image,Ext_Size,Dir_V);
  1354.                   if rem(delta_V,2)
  1355.                       New_Image = wkeep2(New_Image,Desired_Size,'c','dr');
  1356.                   end
  1357.               end
  1358.               imgxtool('draw',win_imgxtool,Anal_Image,New_Image, ...
  1359.                           [Image_Lims_O;Image_Lims_N]);
  1360.           case xlate('Extend')
  1361.               Deb_N_H = 1;
  1362.               Deb_N_V = 1;
  1363.               delta_H = Desired_length_H - Image_length_H;
  1364.               delta_V = Desired_length_V - Image_length_V ;
  1365.               switch Str_pop_direct_H
  1366.                 case 'Left'  , Deb_O_H = 1 + delta_H;
  1367.                 case 'Right' , Deb_O_H = 1;
  1368.                 case 'Both'  , Deb_O_H = 1 + fix(delta_H/2);
  1369.               end
  1370.               switch Str_pop_direct_V
  1371.                 case 'Up'   , Deb_O_V = 1 + delta_V;
  1372.                 case 'Down' , Deb_O_V = 1;
  1373.                 case 'Both' , Deb_O_V = 1 + fix(delta_V/2);
  1374.               end
  1375.               Fin_O_H      = Deb_O_H + Image_length_H - 1;
  1376.               Fin_O_V      = Deb_O_V + Image_length_V - 1;
  1377.               Fin_N_H      = Deb_N_H + Desired_length_H - 1;
  1378.               Fin_N_V      = Deb_N_V + Desired_length_V - 1;
  1379.               Image_Lims_O = [Deb_O_H Fin_O_H Deb_O_V Fin_O_V];
  1380.               Image_Lims_N = [Deb_N_H Fin_N_H Deb_N_V Fin_N_V];
  1381.               switch Dir_H
  1382.                 case {'l','r'}
  1383.                   New_Image = wextend('ac',Mode,Anal_Image,delta_H,Dir_H);
  1384.                 case 'b'
  1385.                   Ext_Size  = ceil(delta_H/2);
  1386.                   New_Image = wextend('ac',Mode,Anal_Image,Ext_Size,Dir_H);
  1387.               end
  1388.               switch Dir_V
  1389.                 case {'u','d'}
  1390.                   New_Image  = wextend('ar',Mode,New_Image,delta_V,Dir_V);
  1391.                 case 'b'
  1392.                   Ext_Size  = ceil(delta_V/2);
  1393.                   New_Image = wextend('ar',Mode,New_Image,Ext_Size,Dir_V);
  1394.               end
  1395.               if rem(delta_H,2) | rem(delta_V,2)
  1396.                   New_Image = wkeep2(New_Image,Desired_Size,'c','dr');
  1397.               end
  1398.               imgxtool('draw',win_imgxtool,Anal_Image,New_Image, ...
  1399.                           [Image_Lims_O;Image_Lims_N]);
  1400.         end
  1401.         % Saving the new image.
  1402.         %-----------------------
  1403.         wfigmngr('storeValue',win_imgxtool,'New_Image',New_Image);
  1404.         % End waiting.
  1405.         %-------------
  1406.         wwaiting('off',win_imgxtool);
  1407.         
  1408.     case 'draw'
  1409.     %-----------------------------------------------------%
  1410.     % Option: 'DRAW' - Plot both new and original signals %
  1411.     %-----------------------------------------------------%
  1412.         % Get arguments.
  1413.         %---------------
  1414.         Anal_Image = varargin{2};
  1415.         New_Image  = varargin{3};
  1416.         Image_Lims = varargin{4};
  1417.         Deb_O_H    = Image_Lims(1,1);
  1418.         Fin_O_H    = Image_Lims(1,2);
  1419.         Deb_O_V    = Image_Lims(1,3);
  1420.         Fin_O_V    = Image_Lims(1,4);
  1421.         Deb_N_H    = Image_Lims(2,1);
  1422.         Fin_N_H    = Image_Lims(2,2);
  1423.         Deb_N_V    = Image_Lims(2,3);
  1424.         Fin_N_V    = Image_Lims(2,4);
  1425.         
  1426.         % Begin waiting.
  1427.         %---------------
  1428.         wwaiting('msg',win_imgxtool,'Wait ... drawing');
  1429.         
  1430.         % Get Axes Handles.
  1431.         %------------------
  1432.         Axe_Img =  Hdls_Axes.Axe_Img;
  1433.         Axe_Leg =  Hdls_Axes.Axe_Leg;
  1434.         % Clean images axes.
  1435.         %--------------------
  1436.         delete(findobj(Axe_Img,'Type','image'));
  1437.         delete(findobj(Axe_Img,'Type','line'));
  1438.         % Compute axes limits.
  1439.         %---------------------
  1440.         Xmin = min(Deb_O_H,Deb_N_H)-1;
  1441.         Xmax = max(Fin_O_H,Fin_N_H)+1;
  1442.         Ymin = min(Deb_O_V,Deb_N_V)-1;
  1443.         Ymax = max(Fin_O_V,Fin_N_V)+1;
  1444.         % Compute image ratio.
  1445.         %---------------------
  1446.         Len_X = Xmax - Xmin;
  1447.         Len_Y = Ymax - Ymin;
  1448.         
  1449.         % Compute new Axes position to respect a good ratio.
  1450.         %---------------------------------------------------
  1451.         [w,h]          = wpropimg([Len_X Len_Y],Pos_Axe_Img_Ori(3), ...
  1452.                                    Pos_Axe_Img_Ori(4));
  1453.         Pos_Axe_Img    = Pos_Axe_Img_Ori;
  1454.         Pos_Axe_Img(1) = Pos_Axe_Img(1)+abs(Pos_Axe_Img(3)-w)/2;
  1455.         Pos_Axe_Img(2) = Pos_Axe_Img(2)+abs(Pos_Axe_Img(4)-h)/2;
  1456.         Pos_Axe_Img(3) = w;
  1457.         Pos_Axe_Img(4) = h;
  1458.             
  1459.         % Update axes properties.
  1460.         %------------------------
  1461.         set(Axe_Img,                         ...
  1462.             'XTicklabelMode','manual',       ...
  1463.             'YTicklabelMode','manual',       ...
  1464.             'XTicklabel',[],'YTicklabel',[], ...
  1465.             'XTick',[],'YTick',[],           ...
  1466.             'Ydir','reverse',                ...
  1467.             'Box','Off',                     ...
  1468.             'NextPlot','add',                ...
  1469.             'Position',Pos_Axe_Img,          ...
  1470.             'Xlim',[Xmin,Xmax],              ...
  1471.             'Ylim',[Ymin,Ymax],              ...
  1472.             'Xcolor','k',                    ...
  1473.             'Ycolor','k',                    ...
  1474.             'Visible','on'                   ...
  1475.             );
  1476.         set(get(Axe_Img,'title'),'string','');
  1477.             
  1478.         % Draw old image.
  1479.         %----------------
  1480.         Old_Img = image(Anal_Image,                   ...
  1481.                            'parent',Axe_Img,          ...
  1482.                            'Xdata',[Deb_O_H Fin_O_H], ...
  1483.                            'Ydata',[Deb_O_V Fin_O_V]  ...
  1484.                            );
  1485.         % Draw new image.
  1486.         %----------------
  1487.         New_Img = image(New_Image,                    ...
  1488.                            'parent',Axe_Img,          ...
  1489.                            'Xdata',[Deb_N_H Fin_N_H], ...
  1490.                            'Ydata',[Deb_N_V Fin_N_V]  ...
  1491.                            );
  1492.         % Constant coefs. for box design.
  1493.         %--------------------------------
  1494.         S1 = 4;
  1495.         S2 = 4;
  1496.         % Draw Box around old image.
  1497.         %---------------------------
  1498.         X = [Deb_O_H Fin_O_H Fin_O_H Deb_O_H Deb_O_H];
  1499.         Y = [Deb_O_V Deb_O_V Fin_O_V Fin_O_V Deb_O_V];
  1500.         Box_Old_Img = line(X,Y,              ...
  1501.                            'parent',Axe_Img, ...
  1502.                            'color','red',    ...
  1503.                            'LineWidth',S1    ...
  1504.                            );
  1505.         % Draw Box around new image.
  1506.         %----------------------------
  1507.         X = [Deb_N_H Fin_N_H Fin_N_H Deb_N_H Deb_N_H];
  1508.         Y = [Deb_N_V Deb_N_V Fin_N_V Fin_N_V Deb_N_V];
  1509.         Box_New_Img = line(X,Y,              ...
  1510.                            'parent',Axe_Img, ...
  1511.                            'color','yellow', ...
  1512.                            'LineWidth',S2    ...
  1513.                            );
  1514.         % Display Legend.
  1515.         %----------------
  1516.         set(Axe_Leg,'Visible','on');
  1517.         set(get(Axe_Leg,'Children'),'Visible','on');
  1518.         % Dynvtool Attachement.
  1519.         %----------------------
  1520.         dynvtool('init',win_imgxtool,[],Axe_Img,[],[1 1],'','','');
  1521.         % Update File_Save_Flag.
  1522.         %-----------------------
  1523.         File_Save_Flag = 0;
  1524.         wfigmngr('storeValue',win_imgxtool,'File_Save_Flag',File_Save_Flag);
  1525.         
  1526.         % Enable save menu.
  1527.         %------------------
  1528.         set(m_save,'Enable','on');
  1529.         % End waiting.
  1530.         %-------------
  1531.         wwaiting('off',win_imgxtool);
  1532.                 
  1533.     case 'save'
  1534.     %-----------------------------------------%
  1535.     % Option: 'SAVE' - Save transformed image %
  1536.     %-----------------------------------------%
  1537.         % Testing file.
  1538.         %--------------
  1539.         [filename,pathname,ok] = utguidiv('test_save',win_imgxtool, ...
  1540.                                     '*.mat','Save Transformed Image');
  1541.         if ~ok, return; end
  1542.         % Begin waiting.
  1543.         %---------------
  1544.         wwaiting('msg',win_imgxtool,'Wait ... saving');
  1545.         % Restore the new image.
  1546.         %-----------------------
  1547.         X = wfigmngr('getValue',win_imgxtool,'New_Image');
  1548.         % Setting Colormap.
  1549.         %------------------
  1550.         map = cbcolmap('get',win_imgxtool,'self_pal');
  1551.         if isempty(map)
  1552.             maxVal   = max(max(X));
  1553.             nbcolors = round(max([2,min([maxVal,default_nbcolors])]));
  1554.             map = pink(nbcolors);
  1555.         end
  1556.         % Saving transformed Image.
  1557.         %--------------------------
  1558.         [name,ext] = strtok(filename,'.');
  1559.         if isempty(ext) | isequal(ext,'.')
  1560.             ext = '.mat'; filename = [name ext];
  1561.         end
  1562.         try
  1563.           save([pathname filename],'X','map');
  1564.         catch
  1565.           errargt(mfilename,'Save FAILED !','msg');
  1566.         end
  1567.         % Update File_Save_Flag.
  1568.         %-----------------------
  1569.         File_Save_Flag = 1;
  1570.         wfigmngr('storeValue',win_imgxtool,'File_Save_Flag',File_Save_Flag);
  1571.         
  1572.         % Enable save menu.
  1573.         %------------------
  1574.         set(m_save,'Enable','off');
  1575.         
  1576.         % End waiting.
  1577.         %-------------
  1578.         wwaiting('off',win_imgxtool);
  1579.     case 'clear_GRAPHICS'
  1580.     %---------------------------------------------------------------------%
  1581.     % Option: 'CLEAR_GRAPHICS' - Clear graphics and redraw original image %
  1582.     %---------------------------------------------------------------------%
  1583.         % Get arguments.
  1584.         %---------------
  1585.         if length(varargin) > 1, Draw_flag = 0; else Draw_flag = 1; end
  1586.         % Get Axes Handles.
  1587.         %------------------
  1588.         Axe_Img = Hdls_Axes.Axe_Img;
  1589.         Axe_Leg = Hdls_Axes.Axe_Leg;
  1590.         % Set graphics part visible off and redraw original image if needed.
  1591.         %-------------------------------------------------------------------
  1592.         set(Axe_Leg,'Visible','off');
  1593.         set(get(Axe_Leg,'Children'),'Visible','off');
  1594.         
  1595.         if Draw_flag
  1596.             Anal_Image      = wfigmngr('getValue',win_imgxtool,'Anal_Image');
  1597.             Pos_Axe_Img_Bas = wfigmngr('getValue',win_imgxtool, ...
  1598.                                        'Pos_Axe_Img_Bas');
  1599.             set(findobj(Axe_Img,'Type','line'),'Visible','Off');
  1600.             [H,V] = size(Anal_Image);
  1601.             set(get(Axe_Img,'title'),'string',xlate('Original Image'));
  1602.             set(Axe_Img,                         ...
  1603.                 'Xlim',[1,H],                    ...
  1604.                 'Ylim',[1,V],                    ...
  1605.                 'Position',Pos_Axe_Img_Bas,      ...
  1606.                 'Visible','on');
  1607.             set(findobj(Axe_Img,'Type','image'), ...
  1608.                 'parent',Axe_Img,                ...
  1609.                 'Xdata',[1,H],                   ...
  1610.                 'Ydata',[1,V],                   ...
  1611.                 'Cdata',Anal_Image,              ...
  1612.                 'Visible','on'                   ...
  1613.                 );
  1614.             dynvtool('init',win_imgxtool,[],Axe_Img,[],[1 1],'','','');
  1615.         else
  1616.             set(Axe_Img,'Visible','off');
  1617.             set(get(Axe_Img,'Children'),'Visible','off');
  1618.         end
  1619.         % Disable save menu.
  1620.         %-------------------
  1621.         set(m_save,'Enable','off');
  1622.         % Reset the new image.
  1623.         %---------------------
  1624.         wfigmngr('storeValue',win_imgxtool,'New_Image',[]);
  1625.         
  1626.     case 'close'
  1627.     %---------------------------------------%
  1628.     % Option: 'CLOSE' - Close current figure%
  1629.     %---------------------------------------%
  1630.         % Retrieve File_Save_Flag.
  1631.         %-------------------------
  1632.         File_Save_Flag = wfigmngr('getValue',win_imgxtool,'File_Save_Flag');
  1633.         
  1634.         % Retrieve images values.
  1635.         %------------------------
  1636.         New_Image  = wfigmngr('getValue',win_imgxtool,'New_Image');
  1637.         Anal_Image = wfigmngr('getValue',win_imgxtool,'Anal_Image');
  1638.         
  1639.         % Test for saving the new image.
  1640.         %-------------------------------
  1641.         status = 0;
  1642.         if ~isempty(New_Image) & any(size(New_Image)~=size(Anal_Image)) &...
  1643.             ~File_Save_Flag
  1644.             status = wwaitans(win_imgxtool,...
  1645.                      ' Do you want to save the transformed image ?',2,'cond');
  1646.         end
  1647.         switch status
  1648.           case 1 , imgxtool('save',win_imgxtool)
  1649.           case 0 ,
  1650.         end
  1651.         varargout{1} = status;
  1652.         
  1653.     otherwise
  1654.         errargt(mfilename,'Unknown Option','msg');
  1655.         error('*');
  1656. end