entropy_jpeg

PURPOSE ^

It iterates the algorithm for some entropy values. It fits the

SYNOPSIS ^

function [Results_JPEG] = entropy_jpeg(Im,normaliz,To,dUmax,dVmax,uCPv,entropias,directorio,fichero,num_iter,niveles,bitmax)

DESCRIPTION ^

 It iterates the algorithm for some entropy values. It fits the
 uCP, to reach such distortion value.
 It computes the distortions and gives an struct for each entropy value.

 Im         -> Original Image
 normaliz   -> Contrast Normalization
 To         ->
 dUmax      ->
 dVmax      ->
 uCPv       -> Initial uCP value
 niveles    -> Number of quantization levels
 entropias  -> Vector with the entropy values
 directorio -> String with the path to the folder to save BIN and ZIP files.
 fichero    -> String with the name of BIN and ZIP files.

 NOTE THAT: 'entropias' has to be sorted ascent

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 % It iterates the algorithm for some entropy values. It fits the
0003 % uCP, to reach such distortion value.
0004 % It computes the distortions and gives an struct for each entropy value.
0005 %
0006 % Im         -> Original Image
0007 % normaliz   -> Contrast Normalization
0008 % To         ->
0009 % dUmax      ->
0010 % dVmax      ->
0011 % uCPv       -> Initial uCP value
0012 % niveles    -> Number of quantization levels
0013 % entropias  -> Vector with the entropy values
0014 % directorio -> String with the path to the folder to save BIN and ZIP files.
0015 % fichero    -> String with the name of BIN and ZIP files.
0016 %
0017 % NOTE THAT: 'entropias' has to be sorted ascent
0018 
0019 function [Results_JPEG] = entropy_jpeg(Im,normaliz,To,dUmax,dVmax,uCPv,entropias,directorio,fichero,num_iter,niveles,bitmax)
0020 you_are_here=pwd;
0021 
0022 if(nargin < 12 && niveles == 1)
0023     bitmax = 1;
0024 end
0025 
0026 exp_sum = 1:2;
0027 
0028 RMSEs = [];
0029 SSIMs = [];
0030 MPEls = [];
0031 MPEnls = [];
0032 MPEnlJMLRs = [];
0033 SCIELabs = zeros(length(entropias),length(exp_sum));
0034 Results_JPEG = [];
0035 uCPs = zeros(length(entropias),3);
0036 
0037 umbral = 0.005;
0038 
0039 N = 256;
0040 
0041 pesoY = 0.7;
0042 pesoU = 0.15;
0043 pesoV = 0.15;
0044 for i = 1:length(entropias)
0045 
0046     uCP = [0 0 0];
0047 
0048     iter = 0;
0049 
0050     porcentaje = 1;
0051 
0052     sentido = 1;
0053 
0054     l_min = 0;
0055     l_max = 100000;
0056 
0057     ImR_JPEG = [];
0058 
0059     entropia_actual = 0;
0060     disp(['Modifying quantization coarsenes to obtain the target entropy:   ' num2str(entropias(i))]);
0061     while((abs(entropias(i) - entropia_actual) > umbral) && (iter <= num_iter))
0062         iter = iter + 1;
0063 
0064         if(iter ~= 1 && iter ~= 2)
0065             [uCP2,l_min,l_max,porcentaje,sentido] = fitting_uCP_entropy(entropias(i),entropia_actual,uCP(1),l_min,l_max,porcentaje,sentido);
0066             uCP = uCP2 .* [1 1 1];
0067         end
0068 
0069         jpeg91_c_encoder(Im,normaliz,To,dUmax,dVmax,uCP,directorio,[fichero '_jpeg91_c_entropy_' num2str(i)],niveles);
0070 
0071         D = dir([directorio fichero '_jpeg91_c_entropy_' num2str(i) '.zip']);
0072         tamanyo = 8 * D.bytes;
0073 
0074         entropia_actual = tamanyo / N^2;
0075 
0076         disp(['Iterat:  ' num2str(iter) '   Entropy:  ' num2str(entropia_actual) '   Control Paramet:  ' num2str(uCP(1))]);
0077 
0078         if((iter == 1) && (entropias(i) - entropia_actual < 0) && (uCP(1) == 0))
0079             disp('Target entropy is too small to be reached even discarding all AC coefficients');
0080             break;
0081 
0082         elseif((iter == 1) && (abs(entropias(i) - entropia_actual) <= umbral) && (uCP(1) == 0))
0083 
0084             if(i ~= 1)
0085 
0086                 uCP = uCPs(i-1,:);
0087 
0088             else
0089 
0090                 uCP = uCPv(i,:);
0091             end
0092 
0093             entropia_actual = 0;
0094 
0095         elseif(iter == 1)
0096 
0097             if(i ~= 1)
0098 
0099                 uCP = uCPs(i-1,:);
0100 
0101             else
0102 
0103                 uCP = uCPv(i,:);
0104             end
0105         end
0106     end
0107 
0108     uCPs(i,:) = uCP;
0109 
0110     cd(directorio)
0111     unzip([fichero '_jpeg91_c_entropy_' num2str(i) '.zip']);
0112     ristra = read_code([fichero '_jpeg91_c_entropy_' num2str(i) '.bin']);
0113 
0114     delete([fichero '_jpeg91_c_entropy_' num2str(i) '.bin']);
0115 
0116     ImR_JPEG = jpeg91_c_decoder(normaliz,To,dUmax,dVmax,directorio,[fichero '_jpeg91_c_entropy_' num2str(i)],niveles);
0117 
0118     [RMSEs(i),SSIMs(i),MPEls(i),MPEnlJMLRs(i),SCIELabs(i,:)] = computing_distortions_c(Im,ImR_JPEG,[pesoY pesoU pesoV],exp_sum);
0119 
0120     Results_JPEG(i).Normalizacion = normaliz;
0121     Results_JPEG(i).To = To;
0122     Results_JPEG(i).dUmax = dUmax;
0123     Results_JPEG(i).dVmax = dVmax;
0124     Results_JPEG(i).Niveles = niveles;
0125     Results_JPEG(i).RMSE = RMSEs(i);
0126     Results_JPEG(i).SSIM = SSIMs(i);
0127 
0128     for n = 1:length(exp_sum)
0129         eval(['Results_JPEG(i).SCIELab_exp' num2str(exp_sum(n)) ' = SCIELabs(i,n);']);
0130     end
0131     Results_JPEG(i).Entropy = entropia_actual;
0132     Results_JPEG(i).uCP = uCPs(i,:);
0133     Results_JPEG(i).Image = ImR_JPEG;
0134     Results_JPEG(i).ristra = ristra;
0135 end
0136 cd(you_are_here);

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