KeCoDe_encoder_achrom

PURPOSE ^

KeCoDe_ENCODER_ACHROM applies DCT-based image coding algorithms to the

SYNOPSIS ^

function [Results] = KeCoDe_encoder_achrom(Im,algorit,directorio,ficherin,entropias,N_it)

DESCRIPTION ^

 KeCoDe_ENCODER_ACHROM applies DCT-based image coding algorithms to the
 input 256*256 gray scale image to obtain a file with the desired
 entropy (in bits/pixel).

 The program stores the encoded file in the folder\name provided by the user.
 Particular appendices to the given file name will be added depending on the
 selected algorithm (see names below).

 The encoded file can be decoded with KeCoDe_DECODER.M
 Besides, the encoder routine also gives the decoded image, the entropy
 of the code (in bits/pix) and a number of distortion measures.

 Algorithms 1-4 below use quantizers based on human vision models of increasing
 accuracy. Algorithms 5-7 are based on similar vision models and also use
 SVM based selection of transform coefficients.

  * MODEL 1: JPEG91.   Wallace, Comm. of the ACM, Vol.34(4):30-44, (1991)
             block DCT transform coding with quantization based on JPEG-like
             linear CSF vision model. It does not include masking relations at all.
             The name of the encoded file will be: name_jpeg91_entropy_1.zip

             Note, though, that this is not exactly the JPEG standard since
             (1) 16*16 DCT blocks are used, (2) run length encoding, DPCM DC encoding
             and block information arrangement are done in a non-standard way, and (3)
             the final entropy coding is done by the Matlab zip routine.
             Nevertheless this implementation is the appropriate for fair
             comparison with the rest of the algorithms since the above (non-fundamental)
             details are implemented in the same way.

  * MODEL 2: Malo99.   Malo et al., Electr. Lett., Vol.35(13):1067-1068, (1999)
             block DCT transform coding with quantization based on a
             simple (point-wise) non-linear masking model. It includes
             auto-masking but it does not include masking relations among
             coefficients.
             The name of the encoded file will be: name_malo99_entropy_1.zip

  * MODEL 3: Malo06.   Malo et al. IEEE Trans. Im. Proc., Vol.15(1):68-80 (2006)
             block DCT transform plus non-linear divisive normalization
             transform and uniform quantization. This is the proper way to take
             frequency selectivity and all the masking relations into account in
             the quantization process.
             The name of the encoded file will be:  name_malo06_entropy_1.zip

  * MODEL 4: Robinson03. Robinson & Kecman, IEEE Trans. Neur.Nets., Vol.14(4):950-958 (2003)
             block DCT transform plus CSF inspired constant insensitivity
             SVM coefficient selection (RKi-1). SVM based on a rough
             linear vision model.
             The name of the encoded file will be:  name_robinson03_entropy_1.zip

  * MODEL 5: Gomez05.   Gomez et al., IEEE Trans. Neur. Nets., Vol.16(6):1574-1581 (2005)
             block DCT transform coding plus CSF adaptive insensitivity
             SVM coefficient selection. SVM based on an accurate linear vision
             model.
             The name of the encoded file will be:  name_gomez05_entropy_1.zip

  * MODEL 6: Camps08.   Camps et al., J. Mach. Learn. Res., Vol.9(1):49-66 (2008)
             block DCT transform coding plus divisive normalization and
             constant insensitivity SVM coefficient selection.  SVM trained in a
             vision model domain that takes into account frequency seletivity and
             masking relations among coefficients.
             The name of the encoded file will be:  name_camps08_entropy_1.zip

 The bit rate of the above algorithms is controlled by different
 parameters:

   * Algorithms 1-3 depend on the Control Parameter, 'CP'.
     Smaller CP values imply more coarse quantization thus giving smaller
     files and more distorted images.

   * Algorithms 4-6 depend on two parameters:
     (1) the insensitivity parameter of the SVM, 'Epsilon'.
     (2) the number of bits used to encode the SVM weights, 'Bits'.
     For a fixed number of bits, smaller Epsilon values imply keeping more
     support vectors (or coefficients) and hence larger files and better
     quality images.

 The user has to provide a target entropy value. The program then
 sets the values of the control parameters (CP, or Epsilon and Bits) and
 iteratively modifies them to achieve the target entropy for the particular image.

 SYNTAX:
 [Results] = KeCoDe_encoder_achrom(Im,MODEL,'output_folder','name',target_entropies,Num_iterat)

 Input variables:
 ----------------
  * Im             :  256*256 image matrix double precision numbers in the range [0 255]
  * MODEL          :  1-6
  * 'output_folder':  String with the folder where it will be written the output file(s)
  * 'name'         :  String with the name of the output file
                      Note that an appendix to this name will be added
                      depending on the coding algorithm.
  * target_entropies: Vector containing the set of target entropies
                      (an image can be compressed at different entropies
                      with a single call to this function)
                      There will be as many output files as target entropy
                      values.
  * Num_iterat     :  Number of iterations to look for the target entropy

 Output:
 -------
  * Results        :  Struct variable with the following fields

       - Results(i).Image   = Decoded image corresponding to the i-th value
                              of the target entropy vector.
       - Results(i).Entropy = Entropy (in bits/pix): file_size/256^2
       - Results(i).RMSE    = RMSE distortion of the i-th decoded image
       - Results(i).SSIM    = Structural SIMilarity Index of the i-th
                              decoded image.
                              (See Wang et al. IEEE Tr. Im. Proc., 2004
                              for a description of this distortion measure)
       - Results(i).MPE_linear= Maximum Perceptual Error of the i-th decoded
                              image based on a linear CSF vision model.
                              (See Gomez et al. IEEE Tr. Neur. Nets., 2005
                              for a description of this distortion measure)
       - Results(i).MPE_non_linear= Maximum Perceptual Error of the i-th decoded
                              image based on a non linear vision model.
                              (See Camps et al. JMLR, 2008 for a description
                              of this distortion measure)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 %
0003 % KeCoDe_ENCODER_ACHROM applies DCT-based image coding algorithms to the
0004 % input 256*256 gray scale image to obtain a file with the desired
0005 % entropy (in bits/pixel).
0006 %
0007 % The program stores the encoded file in the folder\name provided by the user.
0008 % Particular appendices to the given file name will be added depending on the
0009 % selected algorithm (see names below).
0010 %
0011 % The encoded file can be decoded with KeCoDe_DECODER.M
0012 % Besides, the encoder routine also gives the decoded image, the entropy
0013 % of the code (in bits/pix) and a number of distortion measures.
0014 %
0015 % Algorithms 1-4 below use quantizers based on human vision models of increasing
0016 % accuracy. Algorithms 5-7 are based on similar vision models and also use
0017 % SVM based selection of transform coefficients.
0018 %
0019 %  * MODEL 1: JPEG91.   Wallace, Comm. of the ACM, Vol.34(4):30-44, (1991)
0020 %             block DCT transform coding with quantization based on JPEG-like
0021 %             linear CSF vision model. It does not include masking relations at all.
0022 %             The name of the encoded file will be: name_jpeg91_entropy_1.zip
0023 %
0024 %             Note, though, that this is not exactly the JPEG standard since
0025 %             (1) 16*16 DCT blocks are used, (2) run length encoding, DPCM DC encoding
0026 %             and block information arrangement are done in a non-standard way, and (3)
0027 %             the final entropy coding is done by the Matlab zip routine.
0028 %             Nevertheless this implementation is the appropriate for fair
0029 %             comparison with the rest of the algorithms since the above (non-fundamental)
0030 %             details are implemented in the same way.
0031 %
0032 %  * MODEL 2: Malo99.   Malo et al., Electr. Lett., Vol.35(13):1067-1068, (1999)
0033 %             block DCT transform coding with quantization based on a
0034 %             simple (point-wise) non-linear masking model. It includes
0035 %             auto-masking but it does not include masking relations among
0036 %             coefficients.
0037 %             The name of the encoded file will be: name_malo99_entropy_1.zip
0038 %
0039 %  * MODEL 3: Malo06.   Malo et al. IEEE Trans. Im. Proc., Vol.15(1):68-80 (2006)
0040 %             block DCT transform plus non-linear divisive normalization
0041 %             transform and uniform quantization. This is the proper way to take
0042 %             frequency selectivity and all the masking relations into account in
0043 %             the quantization process.
0044 %             The name of the encoded file will be:  name_malo06_entropy_1.zip
0045 %
0046 %  * MODEL 4: Robinson03. Robinson & Kecman, IEEE Trans. Neur.Nets., Vol.14(4):950-958 (2003)
0047 %             block DCT transform plus CSF inspired constant insensitivity
0048 %             SVM coefficient selection (RKi-1). SVM based on a rough
0049 %             linear vision model.
0050 %             The name of the encoded file will be:  name_robinson03_entropy_1.zip
0051 %
0052 %  * MODEL 5: Gomez05.   Gomez et al., IEEE Trans. Neur. Nets., Vol.16(6):1574-1581 (2005)
0053 %             block DCT transform coding plus CSF adaptive insensitivity
0054 %             SVM coefficient selection. SVM based on an accurate linear vision
0055 %             model.
0056 %             The name of the encoded file will be:  name_gomez05_entropy_1.zip
0057 %
0058 %  * MODEL 6: Camps08.   Camps et al., J. Mach. Learn. Res., Vol.9(1):49-66 (2008)
0059 %             block DCT transform coding plus divisive normalization and
0060 %             constant insensitivity SVM coefficient selection.  SVM trained in a
0061 %             vision model domain that takes into account frequency seletivity and
0062 %             masking relations among coefficients.
0063 %             The name of the encoded file will be:  name_camps08_entropy_1.zip
0064 %
0065 % The bit rate of the above algorithms is controlled by different
0066 % parameters:
0067 %
0068 %   * Algorithms 1-3 depend on the Control Parameter, 'CP'.
0069 %     Smaller CP values imply more coarse quantization thus giving smaller
0070 %     files and more distorted images.
0071 %
0072 %   * Algorithms 4-6 depend on two parameters:
0073 %     (1) the insensitivity parameter of the SVM, 'Epsilon'.
0074 %     (2) the number of bits used to encode the SVM weights, 'Bits'.
0075 %     For a fixed number of bits, smaller Epsilon values imply keeping more
0076 %     support vectors (or coefficients) and hence larger files and better
0077 %     quality images.
0078 %
0079 % The user has to provide a target entropy value. The program then
0080 % sets the values of the control parameters (CP, or Epsilon and Bits) and
0081 % iteratively modifies them to achieve the target entropy for the particular image.
0082 %
0083 % SYNTAX:
0084 % [Results] = KeCoDe_encoder_achrom(Im,MODEL,'output_folder','name',target_entropies,Num_iterat)
0085 %
0086 % Input variables:
0087 % ----------------
0088 %  * Im             :  256*256 image matrix double precision numbers in the range [0 255]
0089 %  * MODEL          :  1-6
0090 %  * 'output_folder':  String with the folder where it will be written the output file(s)
0091 %  * 'name'         :  String with the name of the output file
0092 %                      Note that an appendix to this name will be added
0093 %                      depending on the coding algorithm.
0094 %  * target_entropies: Vector containing the set of target entropies
0095 %                      (an image can be compressed at different entropies
0096 %                      with a single call to this function)
0097 %                      There will be as many output files as target entropy
0098 %                      values.
0099 %  * Num_iterat     :  Number of iterations to look for the target entropy
0100 %
0101 % Output:
0102 % -------
0103 %  * Results        :  Struct variable with the following fields
0104 %
0105 %       - Results(i).Image   = Decoded image corresponding to the i-th value
0106 %                              of the target entropy vector.
0107 %       - Results(i).Entropy = Entropy (in bits/pix): file_size/256^2
0108 %       - Results(i).RMSE    = RMSE distortion of the i-th decoded image
0109 %       - Results(i).SSIM    = Structural SIMilarity Index of the i-th
0110 %                              decoded image.
0111 %                              (See Wang et al. IEEE Tr. Im. Proc., 2004
0112 %                              for a description of this distortion measure)
0113 %       - Results(i).MPE_linear= Maximum Perceptual Error of the i-th decoded
0114 %                              image based on a linear CSF vision model.
0115 %                              (See Gomez et al. IEEE Tr. Neur. Nets., 2005
0116 %                              for a description of this distortion measure)
0117 %       - Results(i).MPE_non_linear= Maximum Perceptual Error of the i-th decoded
0118 %                              image based on a non linear vision model.
0119 %                              (See Camps et al. JMLR, 2008 for a description
0120 %                              of this distortion measure)
0121 %
0122 function [Results] = KeCoDe_encoder_achrom(Im,algorit,directorio,ficherin,entropias,N_it)
0123 warning('off','MATLAB:dispatcher:InexactMatch')
0124 Im=double(Im);
0125 if algorit==1
0126     algoritmo=6;
0127 
0128     Desired_entropy=[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1   1.2 1.4 1.6  1.8 2  2.2];
0129     Approximate_uCP=[1.5 2.6 3.3 3.8 4.4 4.9 5.3 5.7 6.5 7.3 8.1 9    9.9 11 12.2];
0130     for i=1:length(entropias)
0131         if entropias(i)>max(Desired_entropy),
0132             parametro(i)=12.5;
0133         elseif entropias(i)<min(Desired_entropy),
0134             parametro(i)=1.2;
0135         else
0136             parametro(i)=interp1(Desired_entropy,Approximate_uCP,entropias(i));
0137         end
0138     end
0139 elseif algorit==2
0140     algoritmo=7;
0141 
0142     Desired_entropy=[ 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1   1.2 1.4 1.6  1.8 2   2.2];
0143     Approximate_uCP=[ 1.3 2.3 3   3.3 3.7 4.1 4.5 4.8 5.3 5.8 6.3 6.8  7.4 7.8 8.3];
0144     for i=1:length(entropias)
0145         if entropias(i)>max(Desired_entropy),
0146             parametro(i)=8.4;
0147         elseif entropias(i)<min(Desired_entropy),
0148             parametro(i)=1.1;
0149         else
0150             parametro(i)=interp1(Desired_entropy,Approximate_uCP,entropias(i));
0151         end
0152     end
0153 elseif algorit==3
0154     algoritmo=9;
0155 
0156     Desired_entropy=[    0.2 0.3 0.4 0.5 0.6 0.7 0.8 1   1.2 1.4 1.6 1.8 2   2.2];
0157     Approximate_uCP=[    0.3 1.0 1.7 2.1 2.6 2.9 3.3 3.9 4.4 4.9 5.3 5.6 6   6.3];
0158     for i=1:length(entropias)
0159         if entropias(i)>max(Desired_entropy),
0160             parametro(i)=6.5;
0161         elseif entropias(i)<min(Desired_entropy),
0162             parametro(i)=0.15;
0163         else
0164             parametro(i)=interp1(Desired_entropy,Approximate_uCP,entropias(i));
0165         end
0166     end
0167 elseif algorit==4
0168     algoritmo=2;
0169 
0170     Desired_entropy=[ 0.1  0.2 0.3  0.4  0.5   0.6   0.7   0.8   1     1.2    1.4    1.6    1.8    2      2.2];
0171     Approx_Epsilon=[ 23.6 2.9 0.46 0.69 0.012 0.037 0.002 0.016 0.013 0.0004 0.0034 0.0053 0.0016 0.0037 0.0017];
0172     for i=1:length(entropias)
0173         if entropias(i)>max(Desired_entropy),
0174             parametro(i)=0.001;
0175         elseif entropias(i)<min(Desired_entropy),
0176             parametro(i)=25;
0177         else
0178             parametro(i)=interp1(Desired_entropy,Approx_Epsilon,entropias(i));
0179         end
0180     end
0181 elseif algorit==5
0182     algoritmo=3;
0183 
0184     Desired_entropy=[0.1  0.2  0.3  0.4   0.5   0.6   0.7   0.8   1     1.2    1.4   1.6   1.8    2      2.2];
0185     Approx_Epsilon=[15.7 0.18 0.10 0.065 0.009 0.026 0.002 0.012 0.011 0.0003 0.003 0.005 0.0015 0.0033 0.0016];
0186     for i=1:length(entropias)
0187         if entropias(i)>max(Desired_entropy),
0188             parametro(i)=0.001;
0189         elseif entropias(i)<min(Desired_entropy),
0190             parametro(i)=18;
0191         else
0192             parametro(i)=interp1(Desired_entropy,Approx_Epsilon,entropias(i));
0193         end
0194     end
0195 elseif algorit==6
0196     algoritmo=4;
0197 
0198     Desired_entropy=[0.1  0.2  0.3  0.4   0.5   0.6   0.7   0.8   1     1.2    1.4    1.6   1.8    2      2.2];
0199     Approx_Epsilon=[0.79 0.36 0.17 0.08  0.025 0.025 0.004 0.01  0.004 0.0027 0.0024 0.003 0.0036 0.0002 0.0012];
0200     for i=1:length(entropias)
0201         if entropias(i)>max(Desired_entropy),
0202             parametro(i)=0.001;
0203         elseif entropias(i)<min(Desired_entropy),
0204             parametro(i)=1;
0205         else
0206             parametro(i)=interp1(Desired_entropy,Approx_Epsilon,entropias(i));
0207         end
0208     end
0209 else
0210     disp('Not a valid algorithm selection')
0211     algoritmo=1000;
0212 end
0213 if algoritmo<100
0214 
0215     [perfil,K,exponente] = computing_parameters_entropy(algoritmo);
0216     if(algoritmo <= 4)
0217         Results = entropy_svr(algoritmo,entropias,Im,parametro,perfil,K,exponente,directorio,ficherin,N_it);
0218     else
0219         Results = entropy_ucp(algoritmo,entropias,Im,parametro,exponente,directorio,ficherin,N_it);
0220     end
0221 end

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