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

波变换

开发平台:

Matlab

  1. function out1 = wpssnode(option,win_wptool,in3,in4,in5,in6)
  2. %WPSSNODE Plot wavelet packets synthesized node.
  3. %   OUT1 = WPSSNODE(OPTION,WIN_WPTOOL,IN3,IN4,IN5,IN6)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 17-May-1999.
  6. %   Copyright 1995-2002 The MathWorks, Inc.
  7. % $Revision: 1.14 $
  8. % Image Coding Value.
  9. %-------------------
  10. codemat_v = wimgcode('get');
  11. % Tag property of objects.
  12. %-------------------------
  13. tag_nodact    = 'Pop_NodAct';
  14. tag_ss_node   = 'SS_Node';
  15. tag_ss_obj    = 'SS_Obj';
  16. tag_axe_t_lin = 'Axe_TreeLines';
  17. tag_axe_pack  = 'Axe_Pack';
  18. axe_handles   = findobj(get(win_wptool,'Children'),'flat','type','axes');
  19. WP_Axe_Tree   = findobj(axe_handles,'flat','Tag',tag_axe_t_lin);
  20. WP_Axe_Pack   = findobj(axe_handles,'flat','Tag',tag_axe_pack);
  21. SS_text       = findobj(WP_Axe_Tree,'Tag',tag_ss_node);
  22. SS_Obj        = findobj(WP_Axe_Pack,'Tag',tag_ss_obj);
  23. % Miscellaneous Values.
  24. %-------------------------
  25. [txt_color,pack_color,ftn_size] = ...
  26.         wtbutils('wputils','ss_node',get(WP_Axe_Tree,'Xcolor'));
  27. switch option 
  28.     case 'plot'
  29.         % in3 = type ('cs' or 'ds')
  30.         % in4 = dim
  31.         % in5 = handle (line or image)
  32.         % in6 = NB_Col (usefull only  for dim = 2)
  33.         %-----------------------------------------
  34.         if (nargin<6) | isempty(in6) , in6 = 128; end
  35.         axes(WP_Axe_Tree)
  36.         if ~isempty(SS_Obj)
  37.             delete(SS_Obj);
  38.             hdl = get(WP_Axe_Pack,'title');
  39.             col = get(WP_Axe_Pack,'Xcolor');
  40.             set(hdl,'String','Node Action Result ','Color',col);
  41.         end
  42.         str_txt = ['(' in3 ')'];
  43.         if isempty(SS_text)
  44.             btndown_fcn  = [mfilename '(''cba'',' int2str(win_wptool) ...
  45.                             ',' int2str(in4) ',' int2str(in6) ');'];
  46.             SS_text = text(...
  47.                            'Clipping','on',                ...
  48.                            'String', str_txt,              ...
  49.                            'Position',[0.25 0.1 0],        ...
  50.                            'Color',txt_color,              ...
  51.                            'HorizontalAlignment','center', ...
  52.                            'VerticalAlignment','middle',   ...
  53.                            'FontSize',ftn_size,            ...
  54.                            'FontWeight','bold',            ...
  55.                            'ButtonDownFcn',btndown_fcn,    ...
  56.                            'Tag',tag_ss_node               ...
  57.                            );
  58.         else
  59.             set(SS_text,'String', str_txt);
  60.         end
  61.         if in4==1
  62.             set(SS_text,'UserData',get(in5,'Ydata'));
  63.         elseif in4==2
  64.             set(SS_text,'UserData',get(in5,'Cdata'));
  65.         end
  66.     case 'cba'
  67.         pop_act = findobj(win_wptool,'Tag',tag_nodact);
  68.         v       = get(pop_act,'Value');
  69.         switch v
  70.             case 1 , wpssnode('vis',win_wptool,in3,in4);
  71.             case 6 , wpssnode('stat',win_wptool,in3);
  72.         end
  73.     case 'vis'
  74.         % in3 = dim
  75.         % in4 = NB_Col (usefull only  for dim = 2)
  76.         %---------------------------------------
  77.         % Begin waiting.
  78.         %--------------
  79.         wwaiting('msg',win_wptool,'Wait ... computing');
  80.         dim     = in3;
  81.         NB_Col  = in4;
  82.         if isempty(NB_Col) , NB_Col = 128; end
  83.         ssig_rec = get(SS_text,'UserData');
  84.         siz      = size(ssig_rec);
  85.         type_ss  = get(SS_text,'String');
  86.         if findstr('cs',type_ss)
  87.             str_txt = ['Compressed ']; 
  88.         else
  89.             str_txt = ['De-noised ']; 
  90.         end
  91.         delete(get(WP_Axe_Pack,'Children'));
  92.         dynvtool('ini_his',win_wptool,1)
  93.         % title_Color = pack_color;
  94.         title_Color = mextglob('get','Def_TxtColor');
  95.         if dim==1
  96.             str_txt = [str_txt 'Signal']; 
  97.             xmax = max(siz);
  98.             if xmax==1 , xmax = 1+0.01; end
  99.             ymin = min(ssig_rec);   ymax = max(ssig_rec);
  100.             if ymin==ymax , ymin = ymin-0.01; ymax = ymax+0.01; end
  101.             plot(ssig_rec,'Parent',WP_Axe_Pack,...
  102.                  'Color',pack_color,'tag',tag_ss_obj);
  103.             set(WP_Axe_Pack,'XLim',[1 xmax],'Ylim',...
  104.                     [ymin ymax],'Tag',tag_axe_pack);
  105.             wtitle(str_txt,'Parent',WP_Axe_Pack,...
  106.                    'FontSize',ftn_size,'Color',title_Color);
  107.         else
  108.             str_txt = [str_txt 'Image']; 
  109.             im = wimgcode('cod',0,ssig_rec,NB_Col,codemat_v);
  110.             image('CData',im,'tag',tag_ss_obj,'Parent',WP_Axe_Pack);
  111.             wtitle(str_txt,'Parent',WP_Axe_Pack,...
  112.                    'FontSize',ftn_size,'Color',title_Color);
  113.             set(WP_Axe_Pack,'Tag',tag_axe_pack,    ...
  114.                             'Layer','top',         ...
  115.                             'XLim',[1 size(im,2)], ...
  116.                             'Ylim',[1 size(im,1)], ...
  117.                             'Ydir','Reverse'       ...
  118.                             );
  119.         end
  120.         dynvtool('put',win_wptool)
  121.         axes(WP_Axe_Tree);
  122.         % End waiting.
  123.         %-------------
  124.         wwaiting('off',win_wptool);
  125.     case 'stat'
  126.         dim = in3;
  127.         type_ss = get(SS_text,'String');
  128.         if findstr('cs',type_ss) , node = -1; else , node = -2; end
  129.         switch dim
  130.           case 1 , feval('wp1dstat','create',win_wptool,node);
  131.           case 2 , feval('wp2dstat','create',win_wptool,node);
  132.         end
  133.     case 'r_synt'
  134.         out1 = SS_text;
  135.     case 'del'
  136.         delete(SS_text);
  137.         if ~isempty(SS_Obj)
  138.             delete(SS_Obj);
  139.             hdl = get(WP_Axe_Pack,'title');
  140.             col = get(WP_Axe_Pack,'Xcolor');
  141.             set(hdl,'String','Node Action Result ','Color',col);
  142.         end
  143. end