svr_nl_decoder

PURPOSE ^

It decompress a file created using 'svr_nl_encoder' and it recovers the image

SYNOPSIS ^

function [ImR] = svr_nl_decoder(K,exponente,directorio,fichero)

DESCRIPTION ^

 It decompress a file created using 'svr_nl_encoder' and it recovers the image

 USE: [ImR] = svr_nl_decoder(K,exponente,directorio,fichero)

 where:

 K          -> Regression Kernel
 exponente  -> Exponent employed in the compression (1 or 2)
 directorio -> Folder where the file to decompress is
 fichero    -> Name of the .zip file (whithout extension) to decompress

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % It decompress a file created using 'svr_nl_encoder' and it recovers the image
0002 %
0003 % USE: [ImR] = svr_nl_decoder(K,exponente,directorio,fichero)
0004 %
0005 % where:
0006 %
0007 % K          -> Regression Kernel
0008 % exponente  -> Exponent employed in the compression (1 or 2)
0009 % directorio -> Folder where the file to decompress is
0010 % fichero    -> Name of the .zip file (whithout extension) to decompress
0011 
0012 function [ImR] = svr_nl_decoder(K,exponente,directorio,fichero)
0013 Lb = 16;
0014 Li = 256;
0015 
0016 cd(directorio)
0017 unzip([fichero '.zip']);
0018 ristra = read_code_svr_nl([fichero '.bin']);
0019 
0020 delete([fichero '.bin']);
0021 TheCode = zeros(256,255);
0022 
0023 normaliz = [3 ristra(1)];
0024 extr_err = ristra(2:3);
0025 QE = reshape(ristra(4:3+256),16,16);
0026 bits = ristra(260);
0027 
0028 ristra = ristra(261:end);
0029 
0030 [TheCode] = inv_rle(ristra);
0031 
0032 NumNiv = 2^bits;
0033 MM = 0.8;
0034 
0035 TheRealCode = TheCode * MM / NumNiv;
0036 
0037 N = round(0.9 * 40);
0038 qe = (extr_err(2) - extr_err(1)) * QE / (N - 1) + extr_err(1);
0039 
0040 Lmq = iimdpcm(qe,1,100);
0041 DC = 16 * Lmq;
0042 DC = DC';
0043 DC = DC(:);
0044 
0045 cero = 1;
0046 aa = zeros(Lb);
0047 [h,alpha,beta,gamm] = constrains_resp(exponente,cero);
0048 [h_a,r,GR,alfa2d,beta2d] = respue5(aa,alpha,beta,gamm,h,0);
0049 
0050 fprintf('Recovering the image:\n');
0051 fprintf('  Inverting from SVM weights to the non-linear domain\n');
0052 fprintf('  Inverting from the non-linear domain to DCT\n');
0053 z = 1;
0054 Db = diag(beta2d);
0055 Identidad = eye(size(h));
0056 
0057 TheRealCode2 = TheRealCode';
0058 
0059 for i=1:Lb:(Li-1)
0060     fprintf('.');
0061     for j=1:Lb:(Li-1)
0062 
0063         r_recon = K * TheRealCode2(:,z);
0064         signosr = r_recon < 0;
0065         r_recon = [0; abs(r_recon)];
0066 
0067         Dr = diag(r_recon);
0068         ac = ((inv(Identidad-Dr*h)*Db*r_recon).^(1/gamm))./alfa2d;
0069 
0070         ac_c = ac(2:end);
0071         acs = ac_c.*(signosr==0) - ac_c.*(signosr>0);
0072         acs = [0;acs];
0073         acs = dezigzag(acs);
0074 
0075         acs(1,1) = DC(z);
0076         dctc1(i:(i+(Lb-1)),j:(j+(Lb-1))) = acs;
0077         z = z+1;
0078     end
0079 end
0080 fprintf('  Inverting from DCT to spatial domain\n');
0081 
0082 dctc1i = icontra2(dctc1,Lmq,4,normaliz);
0083 
0084 ImR = real(idct2r(dctc1i,4));

Generated on Fri 07-Mar-2014 13:29:20 by m2html © 2005