ezw_encode.m

来自「EZW implementation which will use wavele」· M 代码 · 共 55 行

M
55
字号
%*********************************%   

%*********EZW encoder*************%

%*********************************%

function [DD,L1,SS,L2]=ezw_encode(X,LEVEL)
Y0=max(X);
Y1=max(Y0); %找到像素中最大值

%设最初门限制
     for i=0:20;
         if 2^i<=Y1 & 2^i>0.5*Y1;
             threshold=2^i;
             initialthreshold=threshold;
             laststeplevel=i+1;
             break;
         end;
     end;
     
sublist=[];
[xx,yy]=size(X);
A=mapping(xx); %排搜索顺序
[m,n]=size(A);

global N;      % Let Morton scanorder vector as a global variable
N=zeros(m*n,2);
    for i=1:m,
        for j=1:n,
            N(A(i,j),1)=i;
            N(A(i,j),2)=j;
        end
    end

order=1; 
L1=[0];
L2=[0];
DD=[];
SS=[];
while threshold ~= 0.5 & order <= LEVEL,  % if threshold~=0.5, do dominantpass and subordinatepass.
    %Dominant Pass
      [D,X,sublist] = dominantpass(X,threshold,sublist); 
      DD=[DD,D];
      L1=[L1,size(D,2)];
    %Subordinate Pass
      threshold=threshold/2;
      if threshold ==0.5,
          break;
      end
      S = subordinatepass(sublist,threshold);
      SS=[SS,S];
      L2=[L2,size(S,2)];
      
    order=order+1; 
end

⌨️ 快捷键说明

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