malo06_decoder

PURPOSE ^

Unzip a file created with 'malo06_encoder' and retrieve the image

SYNOPSIS ^

function [ImR] = malo06_decoder(exponente,directorio,fichero)

DESCRIPTION ^

 Unzip a file created with 'malo06_encoder' and retrieve the image

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

 Where:

 Exponente -> You can take the values ​​1 or 2 and must match the
 used in malo06_encoder
 Directorio -> Where is the file to decompress
 Fichero -> zip file name (without the extension) to decompress.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 % Unzip a file created with 'malo06_encoder' and retrieve the image
0003 %
0004 % USE: [ImR] = malo06_decoder (exponente, directorio, fichero)
0005 %
0006 % Where:
0007 %
0008 % Exponente -> You can take the values ​​1 or 2 and must match the
0009 % used in malo06_encoder
0010 % Directorio -> Where is the file to decompress
0011 % Fichero -> zip file name (without the extension) to decompress.
0012 
0013 function [ImR] = malo06_decoder(exponente,directorio,fichero)
0014 
0015 Lb = 16;
0016 Li = 256;
0017 
0018 cd(directorio)
0019 unzip([fichero '.zip']);
0020 ristra = read_code_malo06([fichero '.bin']);
0021 
0022 delete([fichero '.bin']);
0023 
0024 TheCode = zeros(256,255);
0025 
0026 normaliz = [3 ristra(1)];
0027 extr_err = ristra(2:3);
0028 QE = reshape(ristra(4:3+256),16,16);
0029 uCP = ristra(260);
0030 
0031 ristra = ristra(261:end);
0032 
0033 [TheCode] = inv_rle(ristra);
0034 
0035 NumNiv = 2^uCP;
0036 MM = 0.8;
0037 
0038 TheRealCode = TheCode * MM / NumNiv;
0039 
0040 Nc = round(0.9 * 40);
0041 qe = (extr_err(2) - extr_err(1)) * QE / (Nc - 1) + extr_err(1);
0042 
0043 Lmq = iimdpcm(qe,1,100);
0044 
0045 aa = zeros(Lb);
0046 [h,kk1,kk2,gamm] = constrains_resp(exponente,1);
0047 [h_a,r,grad,alfa,beta] = respue5(aa,kk1,kk2,gamm,h,0);
0048 
0049 fprintf('Recovering the image:\n');
0050 fprintf('  Inverting from r to dct\n');
0051 
0052 z = 1;
0053 
0054 dctc1 = zeros(Li,Li);
0055 Db = diag(beta);
0056 
0057 for i=1:Lb:(Li-1)
0058     for j=1:Lb:(Li-1)
0059 
0060         r = TheRealCode(z,:)';
0061 
0062         signos = r < 0;
0063 
0064         r = [0; abs(r)];
0065 
0066         Dr = diag(r);
0067 
0068         ac = ((inv(eye(size(h)) - Dr*h) * Db*r) .^ (1/gamm)) ./ alfa;
0069 
0070         ac = ac(2:end);
0071         ac = ac .* (signos == 0) - ac .* (signos == 1);
0072         ac = [0; ac];
0073 
0074         ac = dezigzag(ac);
0075 
0076         dctc1(i:(i+(Lb-1)),j:(j+(Lb-1))) = ac;
0077 
0078         z = z+1;
0079     end
0080 end
0081 
0082 fprintf('  Inverting from dct to spatial domain\n');
0083 
0084 dctc1i = icontra2(dctc1,Lmq,4,normaliz);
0085 
0086 ImR = real(idct2r(dctc1i,4));
0087

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