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

📄 iztc.m

📁 这是一个不错的光谱压缩的Matlab程序,希望它能对你有所帮助.
💻 M
字号:
function pic=iztc(codes,scale,T,M,N)
%用法: pic=iztc(codes,scale,T,M,N)
%功能:对scale级小波分解后的图像pic作零树解码,阈值为T
%codes为code_length*M_step*N_step的三维矩阵,存编码结果
%len为M_step*N_step的二维矩阵,存编码结果的长度
%M,N为图像的行数和列数
%pic为解码生成的图像

%先生成M*N的零矩阵
pic=zeros(M,N);
%量化间隔为8
err=8;

%scale级分解后的图像的行数和列数为M_step和N_step
M_step=M/2^scale;
N_step=N/2^scale;
%scale级分解后的图像的行数和列数为M_step和N_step
bit_len=ceil(log2(T/err));
%一共有M_step*N_step棵零树
for x=1:M_step
  for y=1:N_step
    %对左上角的点单独解码
    code=codes(:,x,y)';
    cur_code=code(1);
    if cur_code=='0'
       pic(x,y)=0;
       code_cnt=2;
    else
       cur_code=code(1:3);
       code_cnt=4;
       value=bin2dec(code(code_cnt:code_cnt+bit_len-1))*err+T+err/2;
       code_cnt=code_cnt+bit_len;
       if cur_code=='101'
         pic(x,y)=value;
       else
         pic(x,y)=-value;
       end
    end
  %将零树的紧接着的三点的坐标放入队列
    stack(1,1:2)=[x,y+N_step];
    stack(2,1:2)=[x+M_step,y];
    stack(3,1:2)=[x+M_step,y+N_step];
    stack_cnt=3;

  %如果队列非空,则一直循环
    while stack_cnt>0
      % 取出队列头的点的坐标作为当前点	
       xx=stack(1,1);
       yy=stack(1,2);
       stack_cnt=stack_cnt-1;
      %队列整理
       for i=1:stack_cnt
         stack(i,:)=stack(i+1,:);
       end
      %当前点解码
       if code(code_cnt)=='0'
         code_cnt=code_cnt+1;
       else
         cur_code=code(code_cnt:code_cnt+2);
         code_cnt=code_cnt+3;
         if  cur_code=='100'
            pic(xx,yy)=0;
         else
            value=bin2dec(code(code_cnt:code_cnt+bit_len-1))*err+T+err/2;
            code_cnt=code_cnt+bit_len;
            if cur_code=='101'
              pic(xx,yy)=value;
            else
              pic(xx,yy)=-value;
            end
         end
	%如果未到达图像边缘,则将该点四个子节点放入队列尾
         if (xx*2<=M)&(yy*2<=N)
           stack(stack_cnt+1,1:2)=[xx*2-1,yy*2-1];
           stack(stack_cnt+2,1:2)=[xx*2-1,yy*2];
           stack(stack_cnt+3,1:2)=[xx*2,yy*2-1];
           stack(stack_cnt+4,1:2)=[xx*2,yy*2];
           stack_cnt=stack_cnt+4;
         end
       end
     end
  end
end

⌨️ 快捷键说明

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