svr_nl_encoder

PURPOSE ^

SVR_NL DCTs 'retransformadas' of a 2D signal subblock

SYNOPSIS ^

function RESP=svr_nl_encoder(Im,bits,epsilon,K,exponente,directorio,fichero,RESP)

DESCRIPTION ^

 SVR_NL DCTs 'retransformadas' of a 2D signal subblock
 (Currently 256 * 256 resolution 4)

 Difference of QDCT63_2 in allowing the introduction of a mask
 (16 * 16 ) selecting certain coefficients so that,
 increased sequentially, you can simulate the progressive decoding
 (sending bits... : see progressive_coding.m ).
 This mask is introduced into the variable 'progres'.
 If progres = ones ( 16,16 ), the result is the same as using qdct63_2

 Difference of QDCT62 that allows you to not calculate the eigenvalues ​​of the original
 (if you're not interested, it saves time!)

 Represents QDCT62 signal in a domain with (approx.) statistically uncorrelated characteristics
 and uncorrelated perceptually (With perceptual metric identity).

 This is achieved through the divisive normalization: Teo & Heeger, Watson and Simoncelli.
 This transformation depends on its input signal ( state adaptation ).

 It has been shown that this type of response obtains independent statistics ( Simoncelli99 ) and
 perceptually ( Malo99 ) coefficients, and therefore is a suitable domain for
 a scalar quantizer.

 Since the perceptual metric in this domain is the identity apply uniform quantizers
 and flat bit-allocation per coefficient.

 For each block the invertibility is checked [max( eig ( D_R * h )) ], and the inverse is computed
 by using the analytical expression

 It is normalized to local Michaelson contrast and response according NAKA8.m:

 Norm = [1 1] ................ Normalized by the average luminance
 of the subfield considered (local contrast) .

 Norm = [3 Lm] ............... Normalized by the fixed value Lm (global contrast)
 the logical choice is to take Lm = mean ( mean ( Im) );
 ( Mean value in digital levels )

 Range to distribute the quantization levels in the domain response is given
 by the maximum diagonal gradient (acting on contrasts, belonging to
 [ -1.1 ]).

 USE: RESP=svr_nl_encoder(Im,bits,epsilon,K,exponente,directorio,fichero,RESP)

 Im        -> Image to compress
 bits      -> Numerb of bits for the SVR weights quantization
 epsilon   -> Regression threshold
 K         -> SVR Kernel
 directorio -> Place where the compressed file will be stored
 fichero -> name with which the compressed file will be stored
 RESP -> Optional parameter : nonlinear transform image
      In the first execution this parameter may not be available,
       but in a loop search of a certain entropy or
       distortion is calculated the first time and avoiding load
       posterior calculation.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % SVR_NL DCTs 'retransformadas' of a 2D signal subblock
0002 % (Currently 256 * 256 resolution 4)
0003 %
0004 % Difference of QDCT63_2 in allowing the introduction of a mask
0005 % (16 * 16 ) selecting certain coefficients so that,
0006 % increased sequentially, you can simulate the progressive decoding
0007 % (sending bits... : see progressive_coding.m ).
0008 % This mask is introduced into the variable 'progres'.
0009 % If progres = ones ( 16,16 ), the result is the same as using qdct63_2
0010 %
0011 % Difference of QDCT62 that allows you to not calculate the eigenvalues ​​of the original
0012 % (if you're not interested, it saves time!)
0013 %
0014 % Represents QDCT62 signal in a domain with (approx.) statistically uncorrelated characteristics
0015 % and uncorrelated perceptually (With perceptual metric identity).
0016 %
0017 % This is achieved through the divisive normalization: Teo & Heeger, Watson and Simoncelli.
0018 % This transformation depends on its input signal ( state adaptation ).
0019 %
0020 % It has been shown that this type of response obtains independent statistics ( Simoncelli99 ) and
0021 % perceptually ( Malo99 ) coefficients, and therefore is a suitable domain for
0022 % a scalar quantizer.
0023 %
0024 % Since the perceptual metric in this domain is the identity apply uniform quantizers
0025 % and flat bit-allocation per coefficient.
0026 %
0027 % For each block the invertibility is checked [max( eig ( D_R * h )) ], and the inverse is computed
0028 % by using the analytical expression
0029 %
0030 % It is normalized to local Michaelson contrast and response according NAKA8.m:
0031 %
0032 % Norm = [1 1] ................ Normalized by the average luminance
0033 % of the subfield considered (local contrast) .
0034 %
0035 % Norm = [3 Lm] ............... Normalized by the fixed value Lm (global contrast)
0036 % the logical choice is to take Lm = mean ( mean ( Im) );
0037 % ( Mean value in digital levels )
0038 %
0039 % Range to distribute the quantization levels in the domain response is given
0040 % by the maximum diagonal gradient (acting on contrasts, belonging to
0041 % [ -1.1 ]).
0042 %
0043 % USE: RESP=svr_nl_encoder(Im,bits,epsilon,K,exponente,directorio,fichero,RESP)
0044 %
0045 % Im        -> Image to compress
0046 % bits      -> Numerb of bits for the SVR weights quantization
0047 % epsilon   -> Regression threshold
0048 % K         -> SVR Kernel
0049 % directorio -> Place where the compressed file will be stored
0050 % fichero -> name with which the compressed file will be stored
0051 % RESP -> Optional parameter : nonlinear transform image
0052 %      In the first execution this parameter may not be available,
0053 %       but in a loop search of a certain entropy or
0054 %       distortion is calculated the first time and avoiding load
0055 %       posterior calculation.
0056 
0057 function RESP=svr_nl_encoder(Im,bits,epsilon,K,exponente,directorio,fichero,RESP)
0058 
0059 if nargin<8
0060    RESP=[];
0061 end
0062 
0063 MM = 0.8;
0064 normaliz = [3 mean(mean(Im))];
0065 cero = 1;
0066 
0067 [h,alpha,beta,gamm] = constrains_resp(exponente,cero);
0068 
0069 Ncuan=4;
0070 tam=size(Im);
0071 tam=tam(1);
0072 lados=[tam tam];
0073 lcuan=tam/(2^Ncuan);
0074 
0075 posai=[tam tam]/2-round(tam/2);
0076 posbd=[tam tam]/2+round(tam/2);
0077 coorcuanai=floor([(posai(1)-1)/lcuan+1 (posai(2)-1)/lcuan+1]);
0078 coorcuanbd=floor([(posbd(1)-1)/lcuan+1 (posbd(2)-1)/lcuan+1]);
0079 if coorcuanai(1)<1
0080     coorcuanai(1)=1;
0081 end
0082 if coorcuanai(2)<1
0083     coorcuanai(2)=1;
0084 end
0085 if coorcuanbd(1)>(2^Ncuan)
0086     coorcuanbd(1)=2^Ncuan;
0087 end
0088 if coorcuanai(2)>(2^Ncuan)
0089     coorcuanbd(2)=2^Ncuan;
0090 end
0091 
0092 dcti=dct2r(Im,Ncuan);
0093 
0094 [dct_contr,Lm] = contras2(dcti,Ncuan,normaliz);
0095 DC = Lm*16;
0096 
0097 W=1;
0098 
0099 val_r = 100;
0100 
0101 e = imdpcm(Lm,W,val_r);
0102 
0103 N = round(0.9 * 40);
0104 
0105 me = mini(e);
0106 Me = maxi(e);
0107 
0108 extr_err = [me Me];
0109 
0110 QE = round((N -1) * (e - me) / (Me - me));
0111 
0112 R=(1:255);R=R(:);
0113 
0114 C=40000;
0115 perfil_C=ones(255,1);
0116 
0117 perfil_e=ones(255,1);
0118 
0119 Lb = lcuan;
0120 Li = tam;
0121 
0122 Results=[];
0123 
0124 codigazo = [];
0125 
0126 signosr = zeros(256,255);
0127 betasc =  zeros(256,255);
0128 betascr = zeros(256,255);
0129 
0130 if nargin<8
0131    fprintf('  Computing the non-linear response \n');
0132    fprintf('  SVM learning the blocks of the local non-linear domain');
0133 else
0134    fprintf('  SVM learning the blocks of the local non-linear domain');
0135 end
0136 
0137 bloquecito = 1;
0138 for i=1:Lb:Li
0139 
0140     fprintf('.');
0141 
0142     for j=1:Lb:Li
0143 
0144         aa = dct_contr(i:(i+(Lb-1)),j:(j+(Lb-1)));
0145 
0146         if nargin<8
0147            [h_a,r,GR,alfa2d,beta2d] = respue5(aa,alpha,beta,gamm,h,0);
0148 
0149            r=zigzag(r);
0150 
0151            RESP=[RESP r];
0152         else
0153            r=RESP(:,bloquecito);
0154         end
0155 
0156         [nsv,pesosSVM,bias] = irwls_pd_svr_nobias(R,r(2:256),K,C,perfil_C,epsilon,perfil_e);
0157 
0158         azig = zigzag(aa);
0159         azigsc = azig(2:end);
0160 
0161         bitsig = getsign(azigsc,Lb);
0162 
0163         signosr(bloquecito,:) = bitsig;
0164         betasc(bloquecito,:) = pesosSVM';
0165 
0166         bloquecito = bloquecito + 1;
0167 
0168     end
0169 end
0170 fprintf('\n');
0171 
0172 NumNiv = 2^bits;
0173 
0174 betascr = round( NumNiv * betasc / MM) * MM / NumNiv;
0175 
0176 rc = [];
0177 for fila = 1:Li
0178     rc = [rc; (K*betascr(fila,:)')'];
0179 end
0180 
0181 signos = zeros(size(signosr));
0182 signos(logical(abs(rc)>0))=signosr(logical(abs(rc)>0));
0183 
0184 codigon = betascr.*(~signos) - betascr.*(signos);
0185 
0186 codigonint = codigon * NumNiv / MM;
0187 
0188 for i=1:Lb^2
0189 
0190         [cod,ceros] = rle2(codigonint(i,:));
0191 
0192         codigazo = [codigazo cod ceros];
0193 
0194 end
0195 
0196 ristra = [mean(mean(Im)) extr_err(:)' round(QE(:))' bits round(codigazo)];
0197 
0198 cd(directorio);
0199 save_code_svr_nl(ristra,[fichero '.bin']);
0200 
0201 zip(fichero,[fichero '.bin']);
0202 
0203 delete([fichero '.bin']);
0204

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