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

波变换

开发平台:

Matlab

  1. function varargout = cf1dselc(x,y,axe,in4)
  2. %CF1DSELC Callbacks coefficients 1-D selection box.
  3. %   VARARGOUT = CF1DSELC(X,Y,AXE,IN4)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 22-May-2003.
  6. %   Copyright 1995-2004 The MathWorks, Inc.
  7. %   $Revision: 1.5.4.2 $  $Date: 2004/03/15 22:39:50 $
  8. % in4 = [coefs_axes , -level_anal]
  9. %----------------------------------
  10. varargout   = {[],[]};
  11. coefs_axes  = in4(1:end-1);
  12. axe_coefs_O = coefs_axes(1);
  13. axe_coefs_M = coefs_axes(2);
  14. fig         = get(axe_coefs_O,'Parent');
  15. nameMeth    = utnbcfs('get',fig,'nameMeth');
  16. if ~isequal(nameMeth,'Manual'), return, end
  17. if ~isequal(axe,axe_coefs_O) && ~isequal(axe,axe_coefs_M), return, end
  18. level_anal = in4(end);
  19. abslevel   = abs(level_anal);
  20. z          = round(y);
  21. if     (z<1) || (z>abslevel+1) , val = 0; 
  22. elseif (z<=abslevel)          , val = 1; % Detail
  23. else                          , val = 2; % Approximation
  24. end
  25. if val<1, return; end
  26. [H_vert_O,H_stem_O,H_vert_O_Copy,H_stem_O_Copy,...
  27.  H_vert_M,H_stem_M,H_vert_M_Copy,H_stem_M_Copy] = ...
  28.      cf1dtool('get_Stems_HDL',fig,'allComponents');
  29. if find(axe==axe_coefs_O)
  30.      xy_stem = get(H_stem_O(z),{'Xdata','Ydata'});
  31.      tol = abs(xy_stem{1}(end)-xy_stem{1}(1))/(4*length(xy_stem{1}));
  32.      [ecart,Idx] = min(abs(xy_stem{1}-x));
  33.      if isnan(ecart) ||  ecart>tol , return; end
  34.      % Test for many points
  35.      ii = find(abs(xy_stem{1}-x)==ecart);
  36.      if length(ii)>1
  37.          [dummy,jj] = min(abs(xy_stem{2}(ii)-y));
  38.          Idx = ii(jj);
  39.      end
  40.      xy_stem_Copy = get(H_stem_O_Copy(z),{'Xdata','Ydata'});
  41.      [ecart,Ind] = min(abs(xy_stem_Copy{2}-xy_stem{2}(Idx)));
  42.      xy_vert_Copy = get(H_vert_O_Copy(z),{'Xdata','Ydata'});
  43.      tol = eps;
  44.      if ~isnan(ecart) && ecart<tol
  45.         xy_stem_Copy{1}(Ind) = [];
  46.         xy_stem_Copy{2}(Ind) = [];
  47.         Ind = 3*Ind-4;
  48.         xy_vert_Copy{1}([Ind:Ind+2]) = [];
  49.         xy_vert_Copy{2}([Ind:Ind+2]) = [];
  50.         
  51.         % Update kept coefs.
  52.         %-------------------                                    
  53.         nbKept = utnbcfs('get',fig,'nbKept');
  54.         if z == abslevel+1
  55.            nbKept(1) = nbKept(1) - 1;
  56.         else
  57.            nbKept(abslevel+2-z) = nbKept(abslevel+2-z) - 1;
  58.         end
  59.         nbKept(end) = sum(nbKept(1:end-1));
  60.         utnbcfs('set',fig,'nbKept',nbKept);
  61.         
  62.      else
  63.         xy_stem_Copy{1} = [xy_stem_Copy{1} , xy_stem{1}(Idx)];
  64.         xy_stem_Copy{2} = [xy_stem_Copy{2} , xy_stem{2}(Idx)];
  65.         xy_vert_Copy{1} = [xy_vert_Copy{1} , ...
  66.                            xy_stem{1}(Idx) , xy_stem{1}(Idx) , xy_stem{1}(Idx)];
  67.         xy_vert_Copy{2} = [xy_vert_Copy{2} , ...
  68.                                         z  , xy_stem{2}(Idx) ,             NaN];
  69.         % Update kept coefs.
  70.         %-------------------                                    
  71.         nbKept = utnbcfs('get',fig,'nbKept');
  72.         if z == abslevel+1
  73.            nbKept(1) = nbKept(1) + 1;
  74.         else
  75.            nbKept(abslevel+2-z) = nbKept(abslevel+2-z) + 1;
  76.         end
  77.         nbKept(end) = sum(nbKept(1:end-1));
  78.         utnbcfs('set',fig,'nbKept',nbKept);
  79.      end
  80. elseif find(axe==axe_coefs_M)
  81.      % xy_stem = get(H_stem_M(z),{'Xdata','Ydata'});
  82.      xy_stem = get(H_stem_M_Copy(z),{'Xdata','Ydata'});
  83.      tol = abs(xy_stem{1}(end)-xy_stem{1}(1))/(4*length(xy_stem{1}));
  84.      if isequal(tol,0);
  85.          dummy = get(H_stem_O(z),'Xdata');
  86.          tol = abs(dummy(end)-dummy(1))/(4*length(dummy));
  87.          tol = max(tol,sqrt(eps));
  88.      end
  89.      [ecart,Idx] = min(abs(xy_stem{1}-x));
  90.      if isnan(ecart) ||  ecart>tol , return; end
  91.      % Test for many points
  92.      ii = find(abs(xy_stem{1}-x)==ecart);
  93.      if length(ii)>1
  94.          [dummy,jj] = min(abs(xy_stem{2}(ii)-y));
  95.          Idx = ii(jj);
  96.      end
  97.      xy_stem_Copy = get(H_stem_M_Copy(z),{'Xdata','Ydata'});
  98.      [ecart,Ind]  = min(abs(xy_stem_Copy{2}-xy_stem{2}(Idx)));
  99.      xy_vert_Copy = get(H_vert_M_Copy(z),{'Xdata','Ydata'});
  100.      tol = eps;
  101.      if ~isnan(ecart) && ecart<tol
  102.         xy_stem_Copy{1}(Ind) = [];
  103.         xy_stem_Copy{2}(Ind) = [];
  104.         Ind = 3*Ind-4;
  105.         xy_vert_Copy{1}([Ind:Ind+2]) = [];
  106.         xy_vert_Copy{2}([Ind:Ind+2]) = [];
  107.         
  108.         % Update kept coefs.
  109.         %-------------------                                    
  110.         nbKept = utnbcfs('get',fig,'nbKept');
  111.         if z == abslevel+1
  112.            nbKept(1) = nbKept(1) - 1;
  113.         else
  114.            nbKept(abslevel+2-z) = nbKept(abslevel+2-z) - 1;
  115.         end
  116.         nbKept(end) = sum(nbKept(1:end-1));
  117.         utnbcfs('set',fig,'nbKept',nbKept);
  118.      end                 
  119. else
  120.      return
  121. end
  122. set([H_stem_O_Copy(z),H_stem_M_Copy(z)],...
  123.     'Xdata',xy_stem_Copy{1},...
  124.     'Ydata',xy_stem_Copy{2} ...
  125.     );
  126. set([H_vert_O_Copy(z),H_vert_M_Copy(z)],...
  127.     'Xdata',xy_vert_Copy{1},...
  128.     'Ydata',xy_vert_Copy{2} ...
  129.     );