svr_dct_encoder

PURPOSE ^

------------------------------------------------- ------------------------

SYNOPSIS ^

function svr_dct_encoder(Im,bits,epsilon,H,perfil,directorio,fichero)

DESCRIPTION ^

 ------------------------------------------------- ------------------------
 Svr_dct_encoder block-DCT applied to an image and SVR

 USE: svr_dct_encoder (Im, bits, epsilon, H, listing, directory, file)

 Im         -> Image to compress
 Bits         -> Number of bits for quantization of the weights of the SVR
 Epsilon     -> threshold used in the regression
 H         -> kernel used in SVM
 perfil     -> Profile for epsilon. It is a vector of the same
         size as the vector which is passed to the SVM and
         epsilon affect. This will be the difference for the
         CTE, CSF and RKi algorithms.
 diretorio     -> Place where the compressed file will be stored
 fichero     -> name with which the compressed file will be stored
 ------------------------------------------------- ------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % ------------------------------------------------- ------------------------
0002 % Svr_dct_encoder block-DCT applied to an image and SVR
0003 %
0004 % USE: svr_dct_encoder (Im, bits, epsilon, H, listing, directory, file)
0005 %
0006 % Im         -> Image to compress
0007 % Bits         -> Number of bits for quantization of the weights of the SVR
0008 % Epsilon     -> threshold used in the regression
0009 % H         -> kernel used in SVM
0010 % perfil     -> Profile for epsilon. It is a vector of the same
0011 %         size as the vector which is passed to the SVM and
0012 %         epsilon affect. This will be the difference for the
0013 %         CTE, CSF and RKi algorithms.
0014 % diretorio     -> Place where the compressed file will be stored
0015 % fichero     -> name with which the compressed file will be stored
0016 % ------------------------------------------------- ------------------------
0017 
0018 function svr_dct_encoder(Im,bits,epsilon,H,perfil,directorio,fichero)
0019 
0020 MM = 0.8;
0021 normaliz = [3 mean(mean(Im))];
0022 
0023 Ncuan = 4;
0024 Lb = 16;
0025 Li = length(Im);
0026 
0027 dcti = dct2r(Im,Ncuan);
0028 
0029 [dct_contr,Lm] = contras2(dcti,Ncuan,normaliz);
0030 DC = Lm*16;
0031 
0032 W = 1;
0033 
0034 val_r = 100;
0035 
0036 e = imdpcm(Lm,W,val_r);
0037 
0038 Nc = round(0.9 * 40);
0039 
0040 me = mini(e);
0041 Me = maxi(e);
0042 
0043 extr_err = [me Me];
0044 
0045 QE = round((Nc -1) * (e - me) / (Me - me));
0046 
0047 R = 1:(Lb*Lb-1);
0048 R = R(:);
0049 N = length(R);
0050 C = 40000;
0051 D = ones(1,N);
0052 D = D(:);
0053 
0054 codigazo = [];
0055 
0056 signosr = zeros(256,255);
0057 betasc = zeros(256,255);
0058 betascr = zeros(256,255);
0059 
0060 fprintf('SVM learning the blocks of the local DCT');
0061 
0062 bloquecito = 1;
0063 
0064 for i=1:Lb:Li
0065 
0066     fprintf('.');
0067 
0068     for j=1:Lb:Li
0069 
0070         B = dct_contr(i:(i+(Lb-1)),j:(j+(Lb-1)));
0071 
0072         Bzig = zigzag(B);
0073         Bzig = Bzig(2:end);
0074         bitsig = getsign(Bzig,Lb);
0075         signosr(bloquecito,:) = bitsig;
0076 
0077         [nsv,beta,bias] = irwls_pd_svr_nobias(R,abs(Bzig),H,C,D,epsilon,perfil);
0078 
0079         betasc(bloquecito,:) = beta';
0080 
0081         bloquecito = bloquecito + 1;
0082 
0083     end
0084 end
0085 
0086 fprintf('\n');
0087 
0088 NumNiv = 2^bits;
0089 
0090 betascr = round(NumNiv * betasc / MM) * MM / NumNiv;
0091 
0092 signos = zeros(size(signosr));
0093 signos(logical(betascr ~= 0)) = signosr(logical(betascr ~= 0));
0094 
0095 codigon = betascr.*(~signos) - betascr.*(signos);
0096 codigonint = codigon * NumNiv / MM;
0097 
0098 for i = 1:Lb^2
0099     [cod,ceros] = rle2(codigonint(i,:));
0100     codigazo = [codigazo cod ceros];
0101 end
0102 
0103 ristra = [mean(mean(Im)) extr_err(:)' round(QE(:))' 10*bits round(codigazo)];
0104 
0105 cd(directorio);
0106 save_code_svr_dct(ristra,[fichero '.bin']);
0107 
0108 zip(fichero,[fichero '.bin']);
0109 
0110 delete([fichero '.bin']);

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