malo99_ucp_distortion

PURPOSE ^

MALO99 quantizes 16*16 DCT blocks of 256*256 images using adaptive bit allocation

SYNOPSIS ^

function [Results] = malo99_ucp_distortion(Im,param,B_inicial,variable);

DESCRIPTION ^

 MALO99 quantizes 16*16 DCT blocks of 256*256 images using adaptive bit allocation
 and non-uniform quantizers for each coefficient based on a (point-wise) non-linear
 human vision model (Malo95, Malo99, Malo00).

 In this implementation the allocated bits are controlled by the
 control parameter, CP.
 Increasing CP reduces the quantization step sizes, increasing the entropy,
 and reducing the distortion.

 The algorithm starts by using a CP value provided by the user, uCP.
 This CP value is iteratively modified till the desired entropy is achieved.

 USE: [Results] = malo99_2(Im,parametro,B,variable)

 INPUT:

 Im        -> Image
 parametro -> Distortion parameter value
 B         -> Control parameter
 variable  -> Text string to choose the distortion parameter

 OUTPUT:

 Results   -> Struct with the information a bout results
              to the diostortion parameter:
              struct('uCP',B,'Image',ImR,'Entropy',H)
              Results.SNR, Results.MSE, Results.SSIM, Results.MPE_lineal,
              Results.MPE_no_lineal, Results.MPE_no_linea_JMLR

 REFERENCES:

    Malo et al., Electr. Lett., 1995. (Preliminary version).
    Malo et al., Electr. Lett., 1999. (Restriction of Maximum Perceptual Error).
    Malo et al., Im. Vis. Comp, 2000. (General MPE framework and links with JPEG).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 % MALO99 quantizes 16*16 DCT blocks of 256*256 images using adaptive bit allocation
0003 % and non-uniform quantizers for each coefficient based on a (point-wise) non-linear
0004 % human vision model (Malo95, Malo99, Malo00).
0005 %
0006 % In this implementation the allocated bits are controlled by the
0007 % control parameter, CP.
0008 % Increasing CP reduces the quantization step sizes, increasing the entropy,
0009 % and reducing the distortion.
0010 %
0011 % The algorithm starts by using a CP value provided by the user, uCP.
0012 % This CP value is iteratively modified till the desired entropy is achieved.
0013 %
0014 % USE: [Results] = malo99_2(Im,parametro,B,variable)
0015 %
0016 % INPUT:
0017 %
0018 % Im        -> Image
0019 % parametro -> Distortion parameter value
0020 % B         -> Control parameter
0021 % variable  -> Text string to choose the distortion parameter
0022 %
0023 % OUTPUT:
0024 %
0025 % Results   -> Struct with the information a bout results
0026 %              to the diostortion parameter:
0027 %              struct('uCP',B,'Image',ImR,'Entropy',H)
0028 %              Results.SNR, Results.MSE, Results.SSIM, Results.MPE_lineal,
0029 %              Results.MPE_no_lineal, Results.MPE_no_linea_JMLR
0030 %
0031 % REFERENCES:
0032 %
0033 %    Malo et al., Electr. Lett., 1995. (Preliminary version).
0034 %    Malo et al., Electr. Lett., 1999. (Restriction of Maximum Perceptual Error).
0035 %    Malo et al., Im. Vis. Comp, 2000. (General MPE framework and links with JPEG).
0036 %
0037 
0038 function   [Results] = malo99_ucp_distortion(Im,param,B_inicial,variable);
0039 
0040 Im=double(Im);
0041 
0042 Ncuan=4;
0043 opc=1;
0044 niveles=0;
0045 fronteras=0;
0046 facfreq=1;
0047 ncontr=100;
0048 nolin=1;
0049 estab=0;
0050 Bitmax=10;
0051 metod=0;
0052 fich_est=0;
0053 fc=32;
0054 cc=1;
0055 crit=1;
0056 fijar_max=0;
0057 inccsf=[1 1];
0058 f_baja=0.001;
0059 cal_entr=1;
0060 norma=[1 0];
0061 
0062 Results=[];
0063 
0064 contador = 0;
0065 
0066 for parametro = param
0067 
0068     disp(['Adjustment of uCP to reach desired ' variable ':   ' num2str(parametro)]);
0069 
0070     switch(variable)
0071         case 'SNR', parametro_actual = 1; umbral = 0.05;
0072         case 'MSE', parametro_actual = 1; umbral = 0.5;
0073         case 'SSIM', parametro_actual = 0; umbral = 0.001;
0074         case 'MPE lineal', parametro_actual = 100; umbral = 0.01;
0075         case 'MPE no lineal', parametro_actual = 100; umbral = 0.01;
0076         case 'MPE no lineal JMLR', parametro_actual = 100; umbral = 0.1;
0077     end
0078 
0079     iter = 0;
0080 
0081     B = 0;
0082 
0083     porcentaje = 1;
0084 
0085     if(isequal(variable,'SSIM'))
0086         sentido = 1;
0087     else
0088         sentido = 0;
0089     end
0090 
0091     no_results = 0;
0092 
0093     l_min = 0;
0094     l_max = 100000;
0095 
0096     while(abs(parametro - parametro_actual) > umbral) & (iter < 100)
0097 
0098         iter = iter + 1;
0099 
0100         if(iter ~= 1 & iter ~= 2)
0101             switch(variable)
0102                 case 'SNR',
0103                     [B, l_min, l_max, porcentaje, sentido] = fitting_uCP_SSIM(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0104                 case 'MSE',
0105                     [B, l_min, l_max, porcentaje, sentido] = fitting_uCP(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0106                 case 'SSIM',
0107                     [B, l_min, l_max, porcentaje, sentido] = fitting_uCP_SSIM(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0108                 case 'MPE lineal',
0109                     [B, l_min, l_max, porcentaje, sentido] = fitting_uCP(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0110                 case 'MPE no lineal',
0111                     [B, l_min, l_max, porcentaje, sentido] = fitting_uCP(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0112                 case 'MPE no lineal JMLR',
0113                     [B, l_min, l_max, porcentaje, sentido] = fitting_uCP(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0114             end
0115         end
0116 
0117         [imq,dctq,cod,ciaf1D,iaf,nuqf,niveles,fronteras,H,Hi]=qdct57(Im,Ncuan,opc,niveles,fronteras,facfreq,ncontr,nolin,estab,B,Bitmax,metod,fich_est,fc,cc,crit,fijar_max,inccsf,f_baja,cal_entr,norma);
0118         ImR = imq;
0119 
0120         switch(variable)
0121             case 'SNR',
0122                 [mse,SNRi] = emse2(Im,ImR);
0123                 fprintf('   It. =
0124                 parametro_actual = SNRi;
0125             case 'MSE',
0126                 [mse,SNRi] = emse2(Im,ImR);
0127                 fprintf('   It. =
0128                 parametro_actual = mse;
0129             case 'SSIM',
0130                 esesim = ssim_index(Im,ImR);
0131                 fprintf('   It. =
0132                 parametro_actual = esesim;
0133             case 'MPE lineal',
0134                 [MSE,d_l,dx0,MPEx0,MPEoo0,MPEexpesp0] = disdis_lineal(Im,ImR,2,[3 mean(mean(Im))],2,2);
0135                 mpelin = d_l;
0136                 fprintf('   It. =
0137                 parametro_actual = mpelin;
0138             case 'MPE no lineal',
0139                 [MSE,d,dx,MPEx,MPEoo,MPEexpesp] = disdis7(Im,ImR,[3 mean(mean(Im))],2,1,2,2);
0140                 mpenonlin= d;
0141                 fprintf('   It. =
0142                 parametro_actual = mpenonlin;
0143             case 'MPE no lineal JMLR',
0144                 [MSE,d,dx,MPEx,MPEoo,MPEexpesp] = disdis7(Im,ImR,[3 mean(mean(Im))],1,0.5,2,2);
0145                 mpenonlinJMLR = d;
0146                 fprintf('   It. =
0147                 parametro_actual = mpenonlinJMLR;
0148         end
0149 
0150         if(~isequal(variable,'SSIM') & (iter == 1) & (parametro - parametro_actual > 0) & (B == 0))
0151             no_results = 1;
0152             disp('No se puede ajustar el uCP para esta distorsion');
0153             break;
0154 
0155         elseif(isequal(variable,'SSIM') & (iter == 1) & (parametro - parametro_actual < 0) & (B == 0))
0156             no_results = 1;
0157             disp('No se puede ajustar el uCP para esta distorsion');
0158             break;
0159 
0160         elseif((iter == 1) & (abs(parametro - parametro_actual) <= umbral) & (B == 0))
0161             no_results = 1;
0162             disp('No se puede ajustar el uCP para esta distorsion');
0163             break;
0164 
0165         elseif(iter == 1)
0166             B = B_inicial;
0167         end
0168     end
0169 
0170     if(no_results == 0)
0171 
0172         contador = contador + 1;
0173 
0174         H = Hi/(size(Im,1) * size(Im,2));
0175 
0176         Results(contador).uCP = B;
0177         Results(contador).Image = ImR;
0178         Results(contador).Entropy = H;
0179 
0180         switch(variable)
0181             case 'SNR',
0182                 Results(contador).SNR = SNRi;
0183             case 'MSE',
0184                 Results(contador).MSE = mse;
0185             case 'SSIM',
0186                 Results(contador).SSIM = esesim;
0187             case 'MPE lineal',
0188                 Results(contador).MPE_lineal = mpelin;
0189             case 'MPE no lineal',
0190                 Results(contador).MPE_no_lineal = mpenonlin;
0191             case 'MPE no lineal JMLR',
0192                 Results(contador).MPE_no_lineal_JMLR = mpenonlinJMLR;
0193         end
0194     end
0195 end

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