www.pudn.com > Watermark.rar > 不带神经网络的jpeg压缩试验.m, change:2009-06-25,size:5289b


tu=imread('水印lenna.bmp','bmp'); 
data=tu; 
I=1; 
for q=95 
 imwrite(data,'jpeg压缩.jpg','jpg','quality',q); 
 jimage2=imread('jpeg压缩.jpg','jpg'); 
% imshow(aa); 
 
 
 
wavelet='db1'; 
level=2; 
jimage2=double(jimage2)/255; 
jimage2=jimage2*255; 
Xr=jimage2; 
 
 
% Xr=Xr+Xr_temp_Xr; 
 
[C1,S1]=wavedec2(Xr,level,wavelet); 
jCA2r=appcoef2(C1,S1,wavelet,level); 
jCH2r=detcoef2('h',C1,S1,level); 
jCV2r=detcoef2('v',C1,S1,level); 
jCD2r=detcoef2('d',C1,S1,level); 
 
 jimage1_addr='小波神经网络程序\实验图片\lenna.bmp'; 
jimage1=imread(jimage1_addr,'bmp'); 
wavelet='db1'; 
level=2; 
jimage1=double(jimage1)/255; 
jimage1=jimage1*255; 
[C2,S2]=wavedec2(jimage1,level,wavelet); 
jCA2=appcoef2(C2,S2,wavelet,level); 
jCH2=detcoef2('h',C2,S2,level); 
jCV2=detcoef2('v',C2,S2,level); 
jCD2=detcoef2('d',C2,S2,level); 
 
  
CA2r=2; 
CA2c=2; 
 
row1=48; 
col1=48; 
 
jCA20=zeros(1,CA2r*CA2c); 
jW1=zeros(row1,col1); 
for k1=1:row1 
   for k2=1:col1 
     for i=1:CA2r 
        for j=1:CA2c 
           % CA20(CA2c((CA2c*k-1+i-1)-1)+j)=CA2(CA2r*k-1+i-1,CA2c*k-1+j-1); 
            jCA20(CA2c*(i-1)+j)=jCA2(CA2r*k1-1+i-1,CA2c*k2-1+j-1); 
        end 
     end 
    [jca20,ind] =sort(jCA20,'descend'); 
    index=0; 
    for i=1:CA2r 
        for j=1:CA2c 
            if jCA2(CA2r*k1-1+i-1,CA2c*k2-1+j-1)== jCA20(ind(1)) 
                jW1(k1,k2)=jCA2r(CA2r*k1-1+i-1,CA2c*k2-1+j-1)-jCA2(CA2r*k1-1+i-1,CA2c*k2-1+j-1); 
                index=1; 
                break 
            end 
        end 
            if index==1 
                break 
           end 
    end 
  
   end 
end 
 
CH2r=2; 
CH2c=2; 
jCH20=zeros(1,CH2r*CH2c); 
jW2=zeros(row1,col1); 
for k1=1:row1 
   for k2=1:col1 
     for i=1:CH2r 
        for j=1:CH2c 
           % CH20(CH2c((CH2c*k-1+i-1)-1)+j)=CH2(CH2r*k-1+i-1,CH2c*k-1+j-1); 
            jCH20(CH2c*(i-1)+j)=jCH2(CH2r*k1-1+i-1,CH2c*k2-1+j-1); 
        end 
     end 
    [jch20,ind] =sort(jCH20,'descend'); 
    index=0; 
    for i=1:CH2r 
        for j=1:CH2c 
            if jCH2(CH2r*k1-1+i-1,CH2c*k2-1+j-1)== jCH20(ind(2)) 
                jW2(k1,k2)=jCH2r(CH2r*k1-1+i-1,CH2c*k2-1+j-1)-jCH2(CH2r*k1-1+i-1,CH2c*k2-1+j-1); 
                index=1; 
                break 
            end 
        end 
            if index==1 
                break 
           end 
    end 
  
   end 
end 
 
 
CV2r=2; 
CV2c=2; 
jCV20=zeros(1,CV2r*CV2c); 
jW3=zeros(row1,col1); 
for k1=1:row1 
   for k2=1:col1 
     for i=1:CV2r 
        for j=1:CV2c 
           % CV20(CV2c((CV2c*k-1+i-1)-1)+j)=CV2(CV2r*k-1+i-1,CV2c*k-1+j-1); 
            jCV20(CV2c*(i-1)+j)=jCV2(CV2r*k1-1+i-1,CV2c*k2-1+j-1); 
        end 
     end 
    [jcv20,ind] =sort(jCV20,'descend'); 
  
        for j=1:CV2c 
            if jCV2(CV2r*k1-1+i-1,CV2c*k2-1+j-1)== jCV20(ind(3)) 
                jW3(k1,k2)=jCV2r(CV2r*k1-1+i-1,CV2c*k2-1+j-1)-jCV2(CV2r*k1-1+i-1,CV2c*k2-1+j-1); 
                index=1; 
                break 
            end 
     
    end 
  
   end 
end 
 
 
    [jcd20,ind] =sort(jCD20,'descend'); 
    index=0; 
    for i=1:CD2r 
        for j=1:CD2c 
            if jCD2(CD2r*k1-1+i-1,CD2c*k2-1+j-1)== jCD20(ind(4)) 
                jW4(k1,k2)=jCD2r(CD2r*k1-1+i-1,CD2c*k2-1+j-1)-jCD2(CD2r*k1-1+i-1,CD2c*k2-1+j-1); 
                index=1; 
                break 
            end 
        end 
            if index==1 
                break 
           end 
   
%nbh=mod(mod(mod(mod(T^20,48)^3,48)^3,48)*T^7,48); 
for k=1:4 
    switch k 
        case 1 
            k1=0; 
            k2=0; 
            k3=0; 
            k4=1; 
        case 2 
            k1=0; 
            k2=0; 
            k3=1; 
            k4=1; 
        case 3 
            k1=1; 
            k2=1; 
            k3=0; 
            k4=1; 
        otherwise 
            k1=1; 
            k2=1; 
            k3=1; 
            k4=1; 
    end 
     
   for i=1:row1 
     for j=1:col1 
        ss=[i;j]; 
        ss1=T^(-k1)*T^(-k2)*T^(-k3)*T^(-k4)*ss; 
        ss1=mod(ss1,row1); 
        %ss1=ss1+1; 
         if ss1(1,1)==0 
            ss1(1,1)=48; 
         end 
            if ss1(2,1)==0 
               ss1(2,1)=48; 
            end 
       jW(ss1(1,1),ss1(2,1),k)=jW_temp(i,j,k); 
    end 
   end 
end     
 
jW(:,:,1)=jW(:,:,1)/0.5; 
jW(:,:,2)=jW(:,:,2)/0.7; 
jW(:,:,3)=jW(:,:,3)/0.7; 
jW(:,:,4)=jW(:,:,4)/0.9; 
 
for k=1:4 
   for i=1:48 
      for j=1:48 
        if jW(i,j,k)<0 
           jW(i,j,k)=-1; 
        else 
            jW(i,j,k)=1; 
        end 
      end 
   end 
end 
 
 
 
jW1=jW(:,:,1); 
jW2=jW(:,:,2); 
jW3=jW(:,:,3); 
jW4=jW(:,:,4); 
 
 
 JW=(0.5*jW1+0.7*jW2+0.7*jW3+0.9*jW4)/4;  
         for i=1:48 
             for j=1:48 
                 if JW(i,j)>0 
                      JW(i,j)=1; 
                 else 
                       
                         JW(i,j)=-1; 
                      
                 end 
             end 
         end 
          
          
          
          
         XX=JW; 
          
          for i=1:48 
             for j=1:48 
                 if XX(i,j)>0 
                      XX(i,j)=1; 
                 else 
                       
                       XX(i,j)=0; 
                      
                 end 
             end 
  end 
         imshow(XX); 
         abc(I)=nc(bjay,XX); 
         I=I+1; 
          
end