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

波变换

开发平台:

Matlab

  1. function varargout = dw2ddeno(option,varargin)
  2. %DW2DDENO Discrete wavelet 2-D de-noising.
  3. %   VARARGOUT = DW2DDENO(OPTION,VARARGIN)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 12-Mar-2003.
  6. %   Copyright 1995-2004 The MathWorks, Inc.
  7. %   $Revision: 1.20.4.2 $ $Date: 2004/03/15 22:40:19 $
  8. % Memory Blocks of stored values.
  9. %================================
  10. % MB1.
  11. %-----
  12. n_param_anal   = 'DWAn2d_Par_Anal';
  13. ind_img_name   = 1;
  14. ind_wav_name   = 2;
  15. ind_lev_anal   = 3;
  16. ind_img_t_name = 4;
  17. ind_img_size   = 5;
  18. ind_nbcolors   = 6;
  19. ind_act_option = 7;
  20. ind_simg_type  = 8;
  21. ind_thr_val    = 9;
  22. nb1_stored     = 9;
  23. % MB2.1 and MB2.2.
  24. %-----------------
  25. n_coefs = 'MemCoefs';
  26. n_sizes = 'MemSizes';
  27. % MB1 (local).
  28. %-------------
  29. n_misc_loc = ['MB1_' mfilename];
  30. ind_sav_menus  = 1;
  31. ind_status     = 2;
  32. ind_win_caller = 3;
  33. ind_axe_datas  = 4;
  34. ind_hdl_datas  = 5;
  35. nbLOC_1_stored = 5;
  36. % MB2 (local).
  37. %-------------
  38. n_thrDATA = 'thrDATA';
  39. ind_value = 1;
  40. nbLOC_2_stored = 1;
  41. if ~isequal(option,'create') , win_denoise = varargin{1}; end                                
  42. switch option
  43.     case 'create'
  44.         % Get Globals.
  45.         %-------------
  46.         [Def_Btn_Height,Y_Spacing,Def_FraBkColor] = ...
  47.             mextglob('get','Def_Btn_Height','Y_Spacing','Def_FraBkColor');
  48.         % Calling figure.
  49.         %----------------
  50.         win_caller = varargin{1};
  51.         str_win_caller = sprintf('%.0f',win_caller);
  52.         % Window initialization.
  53.         %----------------------
  54.         win_name = 'Wavelet 2-D  --  De-noising';
  55.         [win_denoise,pos_win,win_units,str_win_denoise,...
  56.              frame0,pos_frame0,Pos_Graphic_Area,pus_close] = ...
  57.                  wfigmngr('create',win_name,'',...
  58.                      'ExtFig_CompDeno',strvcat(mfilename,'cond'));
  59.         set(win_denoise,'userdata',win_caller);
  60.         varargout{1} = win_denoise;
  61. % Add Help for Tool.
  62. %------------------
  63. wfighelp('addHelpTool',win_denoise,'Image De-noising','DW2D_DENO_GUI');
  64. % Add Help Item.
  65. %----------------
  66. wfighelp('addHelpItem',win_denoise,'De-noising Procedure','DENO_PROCEDURE');
  67. wfighelp('addHelpItem',win_denoise,'Available Methods','COMP_DENO_METHODS');
  68.         % Menu construction for current figure.
  69.         %--------------------------------------
  70. m_save  = wfigmngr('getmenus',win_denoise,'save');
  71.         sav_menus(1) = uimenu(m_save,...
  72.                                 'Label','De-noised &Image ',...
  73.                                 'Position',1,                   ...
  74.                                 'Enable','Off',                 ...
  75.                                 'Callback',                     ...
  76.                                 [mfilename '(''save_synt'','    ...
  77.                                         str_win_denoise ');']   ...
  78.                                 );
  79.         sav_menus(2) = uimenu(m_save,...
  80.                                 'Label','&Coefficients ',   ...
  81.                                 'Position',2,                   ...
  82.                                 'Enable','Off',                 ...
  83.                                 'Callback',                     ...
  84.                                 [mfilename '(''save_cfs'','     ...
  85.                                          str_win_denoise ');']  ...
  86.                                 );
  87.         sav_menus(3) = uimenu(m_save,...
  88.                                 'Label','&Decomposition ',  ...
  89.                                 'Position',3,                   ...
  90.                                 'Enable','Off',                 ...
  91.                                 'Callback',                     ...
  92.                                 [mfilename '(''save_dec'','     ...
  93.                                          str_win_denoise ');']  ...
  94.                                 );
  95.         % Begin waiting.
  96.         %---------------
  97.         wwaiting('msg',win_denoise,'Wait ... initialization');
  98.         % Getting  Analysis parameters.
  99.         %------------------------------
  100.         [Img_Name,Img_Size,Wav_Name,Lev_Anal] = ...
  101.         wmemtool('rmb',win_caller,n_param_anal, ...
  102.                        ind_img_name, ...
  103.                        ind_img_size, ...
  104.                        ind_wav_name, ...
  105.                        ind_lev_anal  ...
  106.                        );
  107.         [Wav_Fam,Wav_Num] = wavemngr('fam_num',Wav_Name);
  108.         % General parameters initialization.
  109.         %-----------------------------------
  110.         dy = Y_Spacing;
  111.         str_dir_det = strvcat('Horizontal','Diagonal','Vertical');
  112.         % Command part of the window.
  113.         %============================
  114.         comFigProp = {'Parent',win_denoise,'Unit',win_units};
  115.         % Data, Wavelet and Level parameters.
  116.         %------------------------------------
  117.         xlocINI = pos_frame0([1 3]);
  118.         ytopINI = pos_win(4)-dy;
  119.         toolPos = utanapar('create_copy',win_denoise, ...
  120.                     {'xloc',xlocINI,'top',ytopINI},...
  121.                     {'n_s',{Img_Name,Img_Size},'wav',Wav_Name,'lev',Lev_Anal} ...
  122.                     );
  123.         % denoising tools.
  124.         %-----------------
  125.         ytopTHR = toolPos(2)-4*dy;
  126.         utthrw2d('create',win_denoise, ...
  127.                  'xloc',xlocINI,'top',ytopTHR,...
  128.                  'ydir',-1, ...
  129.                  'visible','on', ...
  130.                  'enable','on', ...
  131.                  'levmax',Lev_Anal, ...
  132.                  'levmaxMAX',Lev_Anal, ...
  133.                  'toolOPT','deno' ...
  134.                  );
  135.         % Adding colormap GUI.
  136.         %---------------------
  137.         briflag = (Lev_Anal<6); 
  138.         if Lev_Anal<6
  139.             pop_pal_caller = cbcolmap('get',win_caller,'pop_pal');
  140.             prop_pal = get(pop_pal_caller,{'String','Value','Userdata'});
  141.             utcolmap('create',win_denoise, ...
  142.                      'xloc',xlocINI, ...
  143.                      'bkcolor',Def_FraBkColor, ...
  144.                      'briflag',briflag, ...
  145.                      'enable','on');
  146.             pop_pal_loc = cbcolmap('get',win_denoise,'pop_pal');
  147.             set(pop_pal_loc,'String',prop_pal{1},'Value',prop_pal{2}, ...
  148.                             'Userdata',prop_pal{3});
  149.             set(win_denoise,'Colormap',get(win_caller,'Colormap'));
  150.         end
  151.         % Graphic part of the window.
  152.         %============================
  153.         % Displaying the window title.
  154.         %-----------------------------
  155.         strX = sprintf('%.0f',Img_Size(2));
  156.         strY = sprintf('%.0f',Img_Size(1));
  157.         str_nb_val   = [' (' strX ' x ' strY ')'];
  158.         str_wintitle = [Img_Name,str_nb_val,' analyzed at level ',...
  159.                         sprintf('%.0f',Lev_Anal),' with ',Wav_Name];
  160.         wfigtitl('string',win_denoise,str_wintitle,'on');
  161.         drawnow
  162.         % Common axes properties.
  163.         %------------------------
  164.         comAxeProp = {...
  165.           comFigProp{:},    ...
  166.           'Units',win_units,...
  167.           'Drawmode','fast',...
  168.           'Box','On',       ...
  169.           'Visible','on'    ...
  170.           };
  171.         % General graphical parameters initialization.
  172.         %--------------------------------------------
  173.         bdx_l   = 0.10*pos_win(3);
  174.         bdx_r   = 0.06*pos_win(3);
  175.         bdx     = 0.08*pos_win(3);
  176.         ecx     = 0.04*pos_win(3);
  177.         bdy     = 0.07*pos_win(4);
  178.         ecy     = 0.03*pos_win(4);
  179.         y_graph = 2*Def_Btn_Height+dy;
  180.         h_graph = pos_frame0(4)-y_graph-Def_Btn_Height;
  181.         w_graph = pos_frame0(1);
  182.         % Building axes for original image.
  183.         %----------------------------------
  184.         x_axe           = bdx;
  185.         w_axe           = (w_graph-ecx-3*bdx/2)/2;
  186.         h_axe           = 0.95*w_axe;
  187.         y_axe           = y_graph+h_graph-w_axe-bdy;
  188.         cx_ori          = x_axe+w_axe/2;
  189.         cy_ori          = y_axe+h_axe/2;
  190.         cx_den          = cx_ori+w_axe+ecx;
  191.         cy_den          = cy_ori;
  192.         [w_used,h_used] = wpropimg(Img_Size,w_axe,h_axe,'pixels');
  193.         pos_axe         = [cx_ori-w_used/2 cy_ori-h_used/2 w_used h_used];
  194.         axe_datas(1)    = axes(comAxeProp{:},'Position',pos_axe);
  195.         axe_orig        = axe_datas(1);
  196.         % Displaying original image.
  197.         %---------------------------
  198.         Img_Anal  = get(dw2drwcd('r_orig',win_caller),'Cdata');
  199.         hdl_datas = [NaN;NaN];
  200.         set(win_denoise,'Colormap',get(win_caller,'Colormap'));
  201.         hdl_datas(1) = image([1 Img_Size(1)],[1,Img_Size(2)],Img_Anal, ...
  202.                               'Parent',axe_orig);
  203.         wtitle('Original image','Parent',axe_orig);
  204.         % Building axes for denoised image.
  205.         %----------------------------------
  206.         pos_axe = [cx_den-w_used/2 cy_den-h_used/2 w_used h_used];
  207.         xylim   = get(axe_orig,{'Xlim','Ylim'});
  208.         axe_datas(2) = axes(comAxeProp{:},...
  209.                             'Visible','off', ...
  210.                             'Position',pos_axe,'Xlim',xylim{1},'Ylim',xylim{2});
  211.         axe_deno = axe_datas(2);
  212.         % Building axes for histograms.
  213.         %------------------------------
  214.         x_axe    = bdx;
  215.         y_axe    = y_graph+bdy;
  216.         h_axe    = (h_graph-w_axe-3*bdy-(Lev_Anal-1)*ecy)/Lev_Anal;
  217.         w_axe    = (w_graph-2*ecx-3*bdx/2)/3;
  218.         pos_axe  = [x_axe y_axe w_axe h_axe];
  219.         axe_hist = zeros(3,Lev_Anal);
  220.         for k = 1:Lev_Anal
  221.             pos_axe(1) = bdx_l;
  222.             pos_axe(2) = y_graph+bdy+(k-1)*(h_axe+ecy);
  223.             for direct=1:3
  224.                 axe_hist(direct,k) = axes(comAxeProp{:},'Position',pos_axe);
  225.                 pos_axe(1) = pos_axe(1)+pos_axe(3)+ecx;
  226.             end
  227.         end
  228.         utthrw2d('set',win_denoise,'axes',axe_hist);
  229.         % Initializing by level threshold.
  230.         %---------------------------------
  231.         maxTHR = zeros(3,Lev_Anal);
  232.         valTHR = dw2ddeno('compute_LVL_THR',win_denoise,win_caller);
  233.         coefs = wmemtool('rmb',win_caller,n_coefs,1);
  234.         sizes = wmemtool('rmb',win_caller,n_sizes,1);
  235.         for d=1:3
  236.             for i=Lev_Anal:-1:1
  237.                 dir = lower(str_dir_det(d,1));
  238.                 c   = detcoef2(dir,coefs,sizes,i);
  239.                 tmp = max(abs(c(:)));
  240.                 if tmp<eps , maxTHR(d,i) = 1;else , maxTHR(d,i) = 1.1*tmp; end
  241.             end
  242.         end
  243.         valTHR = min(maxTHR,valTHR);
  244.         % Displaying details coefficients histograms.
  245.         %--------------------------------------------
  246.         dirDef   = 1;
  247.         fontsize = wmachdep('fontsize','normal');
  248.         col_det  = wtbutils('colors','det',Lev_Anal);
  249.         nb_bins  = 50;
  250.         axeXColor = get(win_denoise,'DefaultAxesXColor');        
  251.         for level = 1:Lev_Anal
  252.             for direct=1:3
  253.                 axeAct  = axe_hist(direct,level);
  254.                 axes(axeAct);
  255.                 dir        = lower(str_dir_det(direct,1));
  256.                 curr_img   = detcoef2(dir,coefs,sizes,level);
  257.                 curr_color = col_det(level,:);
  258.                 his        = wgethist(curr_img(:),nb_bins);
  259.                 his(2,:)   = his(2,:)/length(curr_img(:));
  260.                 hdl_hist   = wplothis(axeAct,his,curr_color);
  261.                 if direct==dirDef
  262.                     txt_hist(direct) = ...
  263.                     txtinaxe('create',['L_' sprintf('%.0f',level)],...
  264.                              axeAct,'left','on',...
  265.                              'bold',fontsize);
  266.                     set(txt_hist(direct),'color',axeXColor);
  267.                 end
  268.                 if level==1
  269.                     wxlabel([deblank(str_dir_det(direct,:)) ' Details'],...
  270.                             'color',axeXColor,...
  271.                             'Parent',axeAct);
  272.                 end
  273.                 thr_val = valTHR(direct,level);
  274.                 thr_max = maxTHR(direct,level);
  275.                 ylim    = get(axeAct,'Ylim');
  276.                 utthrw2d('plot_dec',win_denoise,dirDef, ...
  277.                           {thr_max,thr_val,ylim,direct,level,axeAct})
  278.                 xmax = 1.1*max([thr_max, max(abs(his(1,:)))]);
  279.                 set(axeAct,'Xlim',[-xmax xmax]);
  280.                 set(findall(axeAct),'Visible','on');
  281.             end
  282.         end
  283.         drawnow
  284.         % Initialization of denoising structure.
  285.         %----------------------------------------
  286.         utthrw2d('set',win_denoise,'valthr',valTHR,'maxthr',maxTHR);
  287.         % Memory blocks update.
  288.         %----------------------
  289.         utthrw2d('set',win_denoise,'handleORI',hdl_datas(1));
  290.         wmemtool('ini',win_denoise,n_misc_loc,nbLOC_1_stored);
  291.         wmemtool('wmb',win_denoise,n_misc_loc,   ...
  292.                        ind_sav_menus,sav_menus,  ...
  293.                        ind_status,0,             ...
  294.                        ind_win_caller,win_caller,...
  295.                        ind_axe_datas,axe_datas,  ...
  296.                        ind_hdl_datas,hdl_datas   ...
  297.                        );
  298.         wmemtool('ini',win_denoise,n_thrDATA,nbLOC_2_stored);
  299.         % Axes attachment.
  300.         %-----------------
  301.         axe_cmd = [axe_orig axe_deno];
  302.         axe_act = [];
  303.         dynvtool('init',win_denoise,[],axe_cmd,axe_act,[1 1],'','','','int');
  304.         % Setting units to normalized.
  305.         %-----------------------------
  306.         wfigmngr('normalize',win_denoise);
  307.         % End waiting.
  308.         %-------------
  309.         wwaiting('off',win_denoise);
  310.     case 'denoise'
  311.         % Waiting message.
  312.         %-----------------
  313.         wwaiting('msg',win_denoise,'Wait ... computing');
  314.         % Clear & Get Handles.
  315.         %----------------------
  316.         dw2ddeno('clear_GRAPHICS',win_denoise);
  317.         win_caller = wmemtool('rmb',win_denoise,n_misc_loc,ind_win_caller);
  318.         [axe_datas,hdl_datas] = wmemtool('rmb',win_denoise,n_misc_loc, ...
  319.                                                ind_axe_datas,ind_hdl_datas);
  320.         axe_orig = axe_datas(1);
  321.         axe_deno = axe_datas(2);
  322.         % Getting  Analysis parameters.
  323.         %------------------------------
  324.         [Img_Size,Wav_Name,Lev_Anal] = ...
  325.                 wmemtool('rmb',win_caller,n_param_anal,...
  326.                                ind_img_size, ...
  327.                                ind_wav_name, ...
  328.                                ind_lev_anal  ...
  329.                                );
  330.         % Getting Analysis values.
  331.         %-------------------------
  332.         coefs = wmemtool('rmb',win_caller,n_coefs,1);
  333.         sizes = wmemtool('rmb',win_caller,n_sizes,1);
  334.         % De-noising.
  335.         %------------
  336.         valTHR = utthrw2d('get',win_denoise,'valthr');
  337.         [numMeth,meth,scal,sorh] = utthrw2d('get_LVL_par',win_denoise);
  338.         [xc,cxc,lxc,perf0] = wdencmp('lvd',coefs,sizes,...
  339.                                       Wav_Name,Lev_Anal,valTHR,sorh);
  340.         % Displaying compressed image.
  341.         %------------------------------
  342.         hdl_deno = hdl_datas(2);
  343.         if ishandle(hdl_deno)
  344.             set(hdl_deno,'Cdata',xc,'Visible','on');
  345.         else
  346.             hdl_deno = image([1 Img_Size(1)],[1,Img_Size(2)],xc,...
  347.                               'Parent',axe_deno);
  348.             hdl_datas(2) = hdl_deno;
  349.             utthrw2d('set',win_denoise,'handleTHR',hdl_deno);
  350.             wmemtool('wmb',win_denoise,n_misc_loc,ind_hdl_datas,hdl_datas);
  351.         end
  352.         xylim =  get(axe_orig,{'Xlim','Ylim'});
  353.         set(axe_deno,'Xlim',xylim{1},'Ylim',xylim{2},'Visible','on');
  354.         wtitle('De-noised image','Parent',axe_deno);
  355.         % Memory blocks update.
  356.         %----------------------
  357.         wmemtool('wmb',win_denoise,n_thrDATA,ind_value,{xc,cxc,lxc,valTHR});
  358.         dw2ddeno('enable_menus',win_denoise,'on');
  359.         % End waiting.
  360.         %-------------
  361.         wwaiting('off',win_denoise);
  362.     case 'compute_LVL_THR'
  363.         win_caller = varargin{2};
  364.         [numMeth,meth,alfa,sorh] = utthrw2d('get_LVL_par',win_denoise);
  365.         coefs = wmemtool('rmb',win_caller,n_coefs,1);
  366.         sizes = wmemtool('rmb',win_caller,n_sizes,1);
  367.         varargout{1} = wthrmngr('dw2ddenoLVL',meth,coefs,sizes,alfa);
  368.  
  369.     case 'update_LVL_meth'
  370.         dw2ddeno('clear_GRAPHICS',win_denoise);
  371.         win_caller = wmemtool('rmb',win_denoise,n_misc_loc,ind_win_caller);
  372.         valTHR = dw2ddeno('compute_LVL_THR',win_denoise,win_caller);
  373.         utthrw2d('update_LVL_meth',win_denoise,valTHR);
  374.     case 'clear_GRAPHICS'
  375.         status = wmemtool('rmb',win_denoise,n_misc_loc,ind_status);
  376.         if isempty(status) | isequal(status,0), return; end;
  377.  
  378.         % Disable Toggles and Menus.
  379.         %----------------------------
  380.         dw2ddeno('enable_menus',win_denoise,'off');
  381.         % Get Handles.
  382.         %-------------
  383.         axe_datas = wmemtool('rmb',win_denoise,n_misc_loc,ind_axe_datas);
  384.         axe_deno = axe_datas(2);
  385.         % Setting compressed axes invisible.
  386.         %-----------------------------------
  387.         set(findobj(axe_deno),'visible','off');
  388.         drawnow
  389.     case 'enable_menus'
  390.         enaVal = varargin{2};
  391.         sav_menus = wmemtool('rmb',win_denoise,n_misc_loc,ind_sav_menus);
  392.         set(sav_menus,'Enable',enaVal);
  393.         utthrw2d('enable_tog_res',win_denoise,enaVal);
  394.         if strncmpi(enaVal,'on',2) , status = 1; else , status = 0; end
  395.         wmemtool('wmb',win_denoise,n_misc_loc,ind_status,status);
  396.     case 'save_synt'
  397.  
  398.         % Testing file.
  399.         %--------------
  400.         [filename,pathname,ok] = utguidiv('test_save',win_denoise, ...
  401.                                      '*.mat','Save De-noised Image');
  402.         if ~ok, return; end
  403.         % Begin waiting.
  404.         %--------------
  405.         wwaiting('msg',win_denoise,'Wait ... saving');
  406.         % Getting Analysis values.
  407.         %-------------------------
  408.         win_caller = wmemtool('rmb',win_denoise,n_misc_loc,ind_win_caller);
  409.         wname = wmemtool('rmb',win_caller,n_param_anal,ind_wav_name);
  410.         map = cbcolmap('get',win_caller,'self_pal');
  411.         if isempty(map)
  412.             nb_colors = wmemtool('rmb',win_caller,n_param_anal,ind_nbcolors);
  413.             map = pink(nb_colors);
  414.         end
  415.         thrDATA = wmemtool('rmb',win_denoise,n_thrDATA,ind_value);
  416.         X = round(thrDATA{1});
  417.         valTHR = thrDATA{4};
  418.         % Saving file.
  419.         %--------------
  420.         [name,ext] = strtok(filename,'.');
  421.         if isempty(ext) | isequal(ext,'.')
  422.             ext = '.mat'; filename = [name ext];
  423.         end
  424.         saveStr = {'X','map','valTHR','wname'};
  425.         wwaiting('off',win_denoise);
  426.         try
  427.           save([pathname filename],saveStr{:});
  428.         catch
  429.           errargt(mfilename,'Save FAILED !','msg');
  430.         end
  431.     case 'save_cfs'
  432.         % Testing file.
  433.         %--------------
  434.         [filename,pathname,ok] = utguidiv('test_save',win_denoise, ...
  435.                                      '*.mat','Save Coefficients (2D)');
  436.         if ~ok, return; end
  437.         % Begin waiting.
  438.         %--------------
  439.         wwaiting('msg',win_denoise,'Wait ... saving coefficients');
  440.         % Getting Analysis values.
  441.         %-------------------------
  442.         win_caller = wmemtool('rmb',win_denoise,n_misc_loc,ind_win_caller);
  443.         wname = wmemtool('rmb',win_caller,n_param_anal,ind_wav_name);
  444.         map = cbcolmap('get',win_caller,'self_pal');
  445.         if isempty(map)
  446.             nb_colors = wmemtool('rmb',win_caller,n_param_anal,ind_nbcolors);
  447.             map = pink(nb_colors);
  448.         end
  449.         thrDATA = wmemtool('rmb',win_denoise,n_thrDATA,ind_value);
  450.         coefs  = thrDATA{2};
  451.         sizes  = thrDATA{3};
  452.         valTHR = thrDATA{4};
  453.         % Saving file.
  454.         %--------------
  455.         [name,ext] = strtok(filename,'.');
  456.         if isempty(ext) | isequal(ext,'.')
  457.             ext = '.mat'; filename = [name ext];
  458.         end
  459.         saveStr = {'coefs','sizes','map','valTHR','wname'};
  460.         wwaiting('off',win_denoise);
  461.         try
  462.           save([pathname filename],saveStr{:});
  463.         catch
  464.           errargt(mfilename,'Save FAILED !','msg');
  465.         end
  466.     case 'save_dec'
  467.         % Testing file.
  468.         %--------------
  469.         [filename,pathname,ok] = utguidiv('test_save',win_denoise, ...
  470.                                      '*.wa2','Save Wavelet Analysis (2D)');
  471.         if ~ok, return; end
  472.         % Begin waiting.
  473.         %--------------
  474.         wwaiting('msg',win_denoise,'Wait ... saving decomposition');
  475.         % Getting Analysis values.
  476.         %-------------------------
  477.         win_caller = wmemtool('rmb',win_denoise,n_misc_loc,ind_win_caller);
  478.         [wave_name,data_name,nb_colors] =    ...
  479.                 wmemtool('rmb',win_caller,n_param_anal, ...
  480.                                ind_wav_name, ...
  481.                                ind_img_name, ...
  482.                                ind_nbcolors  ...
  483.                                );
  484.         map = cbcolmap('get',win_caller,'self_pal');
  485.         if isempty(map) , map = pink(nb_colors); end
  486.         thrDATA = wmemtool('rmb',win_denoise,n_thrDATA,ind_value);
  487.         coefs  = thrDATA{2};
  488.         sizes  = thrDATA{3};
  489.         valTHR = thrDATA{4};
  490.         % Saving file.
  491.         %--------------
  492.         [name,ext] = strtok(filename,'.');
  493.         if isempty(ext) | isequal(ext,'.')
  494.             ext = '.wa2'; filename = [name ext];
  495.         end
  496.         saveStr = {'coefs','sizes','wave_name','map','valTHR','data_name'};
  497.         wwaiting('off',win_denoise);
  498.         try
  499.           save([pathname filename],saveStr{:});
  500.         catch
  501.           errargt(mfilename,'Save FAILED !','msg');
  502.         end
  503.     case 'close'
  504.         % Returning or not the denoised image in the 2D current analysis.
  505.         %----------------------------------------------------------------
  506.         [status,win_caller] = wmemtool('rmb',win_denoise,n_misc_loc,...
  507.                                              ind_status,ind_win_caller);
  508.         if status==1
  509.             % Test for Updating.
  510.             %--------------------
  511.             status = wwaitans(win_denoise,...
  512.                               'Update the synthesized image ?',2,'cancel');
  513.         end
  514.         switch status
  515.             case 1
  516.                 wwaiting('msg',win_denoise,'Wait ... computing');
  517.                 thrDATA = wmemtool('rmb',win_denoise,n_thrDATA,ind_value);
  518.                 valTHR  = thrDATA{4};
  519.                 wmemtool('wmb',win_caller,n_param_anal,ind_thr_val,valTHR);
  520.                 hdl_datas = wmemtool('rmb',win_denoise,n_misc_loc,ind_hdl_datas);
  521.                 img = hdl_datas(2);
  522.                 dw2dmngr('return_deno',win_caller,status,img);
  523.                 wwaiting('off',win_denoise);
  524.             case 0
  525.                 dw2dmngr('return_deno',win_caller,status);
  526.         end
  527.         varargout{1} = status;
  528.     otherwise
  529.         errargt(mfilename,'Unknown Option','msg');
  530.         error('*');
  531. end