linbwt2.m

来自「matlab程序」· M 代码 · 共 32 行

M
32
字号
function X = linbwt2(X, Level)
%LINBWT2  2D linear binary wavelet transform.
%   Y = LINBWT2(X,L) computes the L level decomposition of binary
%   image X using a 2D linear binary wavelet wavelet transform.  The
%   transform coefficients are also binary.  The image dimensions
%   must be divisible by 2^L.
%
%   LINBWT2(X,-L) is the inverse transform, reversing L levels.
%
%   Example:
%   Y = linbwt2(X,3);   % Perform 3 levels of decomposition on X
%   R = linbwt2(Y,-3);  % Recover X from Y
%
%   See also LINBWT, MORPHBWT2.

% Pascal Getreuer 2005

if nargin < 2, error('Not enough input arguments.'); end
if rem(size(X),pow2(abs(Level))), error('Invalid input size.'); end

if Level > 0
   for k = 1:Level
      N = size(X)*pow2(1-k);
      X(1:N(1),1:N(2)) = linbwt(linbwt(X(1:N(1),1:N(2)),1,1),1,2);
   end
elseif Level < 0
   for k = Level:-1
      N = size(X)*pow2(k+1);
      X(1:N(1),1:N(2)) = linbwt(linbwt(X(1:N(1),1:N(2)),-1,2),-1,1);
   end
end

⌨️ 快捷键说明

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