⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 medlift.m

📁 matlab程序
💻 M
字号:
function X = medlift(X, Level, Dim)
%MEDLIFT  Lifting based on the median operator.
%   Y = MEDLIFT(X,L) computes the L level decomposition of a signal
%   X using a morphological wavelet using lifting based on the median
%   operator [1].  The signal length must be divisible by 2^L.  If X is
%   a matrix, the transform is applied to each column.
%
%   MEDLIFT(X,-L) is the inverse transform, reversing L levels.
%
%   MEDLIFT(X,L,DIM) applies the transform across the dimension DIM.
%
%   Example:
%   Y = medlift(X,3);   % Perform 3 levels of decomposition on X
%   R = medlift(Y,-3);  % Recover X from Y
%
%   Reference:
%   [1] Heijmans and Goutsias.  ``Nonlinear Multiresolution Signal
%       Decomposition Schemes--Part II: Morphological Wavelets.''  IEEE
%       Transactions on Image Processing, Vol. 9, No. 11, Nov. 2000.
%
%   See also MEDLIFT2, BINWAV2.

% Pascal Getreuer 2005

if nargin < 2, error('Not enough input arguments.'); end
if nargin < 3, Dim = min(find(size(X) ~= 1)); end

XSize = size(X);
N = XSize(Dim);
Perm = [Dim:max(length(XSize),Dim) 1:Dim-1];
X = reshape(permute(X,Perm),N,prod(XSize)/N);

if rem(N,pow2(abs(Level))), error('Invalid input size.'); end

if Level > 0
   for k = 1:Level
      N = size(X,1)*pow2(1-k);
      Xe = X(1:2:N,:);
      Xo = X(2:2:N,:) - Xe;
      A = [Xo(1,:);Xo(1:N/2-1,:)];
      A(:,:,3) = [Xo(2:N/2,:);Xo(N/2,:)];
      A = sort(A,3);
      X(1:N,:) = [Xe + A(:,:,2);Xo];
   end
elseif Level < 0
   for k = Level:-1
      N = size(X,1)*pow2(k+1);
      Xo = X(N/2+1:N,:);
      A = [Xo(1,:);Xo(1:N/2-1,:)];
      A(:,:,3) = [Xo(2:N/2,:);Xo(N/2,:)];
      A = sort(A,3);
      Xe = X(1:N/2,:) - A(:,:,2);
      X([1:2:N,2:2:N],:) = [Xe;Xo + Xe];
   end
end

X = ipermute(reshape(X,XSize(Perm)),Perm);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -