0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 function [Results] = malo06_ucp_distortion(Im,exp,param,B_inicial,variable);
0053
0054 Im=double(Im);
0055
0056 Maximo=0.8;
0057 cero=1;
0058 blo=[];
0059 for i=1:16
0060 for j=1:16
0061 blo=[blo;i j];
0062 end
0063 end
0064 norma=[3 mean(mean(Im))];
0065 calc_eig=0;
0066 calc_eig_sin_q=0;
0067
0068 Results=[];
0069
0070 contador = 0;
0071
0072 for parametro = param
0073
0074 disp(['Adjustment of uCP to reach desired ' variable ': ' num2str(parametro)]);
0075
0076 switch(variable)
0077 case 'SNR', parametro_actual = 1; umbral = 0.05;
0078 case 'MSE', parametro_actual = 1; umbral = 0.5;
0079 case 'SSIM', parametro_actual = 0; umbral = 0.001;
0080 case 'MPE lineal', parametro_actual = 100; umbral = 0.01;
0081 case 'MPE no lineal', parametro_actual = 100; umbral = 0.01;
0082 case 'MPE no lineal JMLR', parametro_actual = 100; umbral = 0.1;
0083 end
0084
0085 iter = 0;
0086
0087 B = 0;
0088
0089 porcentaje = 1;
0090
0091 if(isequal(variable,'SSIM'))
0092 sentido = 1;
0093 else
0094 sentido = 0;
0095 end
0096
0097 no_results = 0;
0098
0099 l_min = 0;
0100 l_max = 100000;
0101
0102 while(abs(parametro - parametro_actual) > umbral) & (iter < 30)
0103
0104 iter = iter + 1;
0105
0106 if(iter ~= 1 & iter ~= 2)
0107 switch(variable)
0108 case 'SNR',
0109 [B, l_min, l_max, porcentaje, sentido] = fitting_uCP_SSIM(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0110 case 'MSE',
0111 [B, l_min, l_max, porcentaje, sentido] = fitting_uCP(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0112 case 'SSIM',
0113 [B, l_min, l_max, porcentaje, sentido] = fitting_uCP_SSIM(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0114 case 'MPE lineal',
0115 [B, l_min, l_max, porcentaje, sentido] = fitting_uCP(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0116 case 'MPE no lineal',
0117 [B, l_min, l_max, porcentaje, sentido] = fitting_uCP(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0118 case 'MPE no lineal JMLR',
0119 [B, l_min, l_max, porcentaje, sentido] = fitting_uCP(parametro, parametro_actual, B, l_min, l_max, porcentaje, sentido);
0120 end
0121 end
0122
0123 [imq1,imq2,codig,signos,codigo,nceros,DC,Hp,Hi,meig,mceig,values,valuesc]=qdct65(Im,B,Maximo,norma,blo,exp,cero,calc_eig,calc_eig_sin_q);
0124 ImR = real(imq1);
0125
0126 switch(variable)
0127 case 'SNR',
0128 [mse,SNRi] = emse2(Im,ImR);
0129 fprintf(' It. =
0130 parametro_actual = SNRi;
0131 case 'MSE',
0132 [mse,SNRi] = emse2(Im,ImR);
0133 fprintf(' It. =
0134 parametro_actual = mse;
0135 case 'SSIM',
0136 esesim = ssim_index(Im,ImR);
0137 fprintf(' It. =
0138 parametro_actual = esesim;
0139 case 'MPE lineal',
0140 [MSE,d_l,dx0,MPEx0,MPEoo0,MPEexpesp0] = disdis_lineal(Im,ImR,2,[3 mean(mean(Im))],2,2);
0141 mpelin = d_l;
0142 fprintf(' It. =
0143 parametro_actual = mpelin;
0144 case 'MPE no lineal',
0145 [MSE,d,dx,MPEx,MPEoo,MPEexpesp] = disdis7(Im,ImR,[3 mean(mean(Im))],2,1,2,2);
0146 mpenonlin= d;
0147 fprintf(' It. =
0148 parametro_actual = mpenonlin;
0149 case 'MPE no lineal JMLR',
0150 [MSE,d,dx,MPEx,MPEoo,MPEexpesp] = disdis7(Im,ImR,[3 mean(mean(Im))],1,0.5,2,2);
0151 mpenonlinJMLR = d;
0152 fprintf(' It. =
0153 parametro_actual = mpenonlinJMLR;
0154 end
0155
0156 if(~isequal(variable,'SSIM') & (iter == 1) & (parametro - parametro_actual > 0) & (B == 0))
0157 no_results = 1;
0158 disp('No se puede ajustar el uCP para esta distorsion');
0159 break;
0160
0161 elseif(isequal(variable,'SSIM') & (iter == 1) & (parametro - parametro_actual < 0) & (B == 0))
0162 no_results = 1;
0163 disp('No se puede ajustar el uCP para esta distorsion');
0164 break;
0165
0166 elseif((iter == 1) & (abs(parametro - parametro_actual) <= umbral) & (B == 0))
0167 no_results = 1;
0168 disp('No se puede ajustar el uCP para esta distorsion');
0169 break;
0170
0171 elseif(iter == 1)
0172 B = B_inicial;
0173 end
0174 end
0175
0176 if(no_results == 0)
0177
0178 contador = contador + 1;
0179
0180 H = Hi/(size(Im,1) * size(Im,2));
0181
0182 Results(contador).uCP = B;
0183 Results(contador).Image = ImR;
0184 Results(contador).Entropy = H;
0185
0186 switch(variable)
0187 case 'SNR',
0188 Results(contador).SNR = SNRi;
0189 case 'MSE',
0190 Results(contador).MSE = mse;
0191 case 'SSIM',
0192 Results(contador).SSIM = esesim;
0193 case 'MPE lineal',
0194 Results(contador).MPE_lineal = mpelin;
0195 case 'MPE no lineal',
0196 Results(contador).MPE_no_lineal = mpenonlin;
0197 case 'MPE no lineal JMLR',
0198 Results(contador).MPE_no_lineal_JMLR = mpenonlinJMLR;
0199 end
0200 end
0201 end