KeCoDe_ENCODER_COLOR applies DCT-based image coding algorithms to the input 256*256*3 RGB color 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_COLOR.M Besides, the encoder routine also gives the decoded image, the entropy of the code (in bits/pix) and a number of distortion measures. * 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 in each chromatic channel (YUV). It does not include masking relations at all. The name of the encoded file will be: name_jpeg91_c_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 other algorithm since the above (non-fundamental) details are implemented in the same way. * MODEL 2: Gutierrez11. Gutierrez et al., Recent Patents in Signal Proc., In press (2011) block DCT transform coding plus chromatic divisive normalization in each YUV channel and constant insensitivity SVM coefficient selection. Dedicated SVMs are trained in a vision model domain that takes into account both frequency seletivity and masking relations among coefficients. The name of the encoded file will be: name_gutierrez09_c_entropy_1.zip The bit rate of the above algorithms is controlled by different parameters: * Algorithm 1 depend on the Control Parameter, 'CP'. Smaller CP values imply more coarse quantization thus giving smaller files and more distorted images. * Algorithm 2 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 useful 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_color(Im,MODEL,'output_folder','name',target_entropies,Num_iterat) Input variables: ---------------- * Im : 256*256*3 image matrix double precision numbers in the range [0 255] * MODEL : 1-2 * '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).SCIELab_exp1= Spatial CIE Lab distortion with summation exponent equal to 1, default in S-CIELab computations. (See Zhang & Wandell, Sig. Proc. 1998 for a description of this distortion measure) - Results(i).SCIELab_exp2= Spatial CIE Lab distortion with summation exponent equal to 2. (See Zhang & Wandell, Sig. Proc. 1998 for a description of this distortion measure)
0001 0002 % 0003 % KeCoDe_ENCODER_COLOR applies DCT-based image coding algorithms to the 0004 % input 256*256*3 RGB color 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_COLOR.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 % * MODEL 1: JPEG91. Wallace, Comm. of the ACM, Vol.34(4):30-44, (1991) 0016 % block DCT transform coding with quantization based on JPEG-like 0017 % linear CSF vision model in each chromatic channel (YUV). 0018 % It does not include masking relations at all. 0019 % The name of the encoded file will be: name_jpeg91_c_entropy_1.zip 0020 % 0021 % Note, though, that this is not exactly the JPEG standard since 0022 % (1) 16*16 DCT blocks are used, (2) run length encoding, DPCM DC encoding 0023 % and block information arrangement are done in a non-standard way, and (3) 0024 % the final entropy coding is done by the Matlab zip routine. 0025 % Nevertheless this implementation is the appropriate for fair 0026 % comparison with the other algorithm since the above (non-fundamental) 0027 % details are implemented in the same way. 0028 % 0029 % * MODEL 2: Gutierrez11. Gutierrez et al., Recent Patents in Signal Proc., In press (2011) 0030 % block DCT transform coding plus chromatic divisive normalization in each 0031 % YUV channel and constant insensitivity SVM coefficient selection. 0032 % Dedicated SVMs are trained in a vision model domain that takes into 0033 % account both frequency seletivity and masking relations among coefficients. 0034 % The name of the encoded file will be: name_gutierrez09_c_entropy_1.zip 0035 % 0036 % The bit rate of the above algorithms is controlled by different 0037 % parameters: 0038 % 0039 % * Algorithm 1 depend on the Control Parameter, 'CP'. 0040 % Smaller CP values imply more coarse quantization thus giving smaller 0041 % files and more distorted images. 0042 % 0043 % * Algorithm 2 depend on two parameters: 0044 % (1) the insensitivity parameter of the SVM, 'Epsilon'. 0045 % (2) the number of bits used to encode the SVM weights, 'Bits'. 0046 % For a fixed number of bits, smaller Epsilon values imply keeping more 0047 % support vectors (or useful coefficients) and hence larger files and better 0048 % quality images. 0049 % 0050 % The user has to provide a target entropy value. The program then 0051 % sets the values of the control parameters (CP, or Epsilon and Bits) and 0052 % iteratively modifies them to achieve the target entropy for the particular image. 0053 % 0054 % SYNTAX: 0055 % [Results] = KeCoDe_encoder_color(Im,MODEL,'output_folder','name',target_entropies,Num_iterat) 0056 % 0057 % Input variables: 0058 % ---------------- 0059 % * Im : 256*256*3 image matrix double precision numbers in the range [0 255] 0060 % * MODEL : 1-2 0061 % * 'output_folder': String with the folder where it will be written the output file(s) 0062 % * 'name' : String with the name of the output file 0063 % Note that an appendix to this name will be added 0064 % depending on the coding algorithm. 0065 % * target_entropies: Vector containing the set of target entropies 0066 % (an image can be compressed at different entropies 0067 % with a single call to this function) 0068 % There will be as many output files as target entropy 0069 % values. 0070 % * Num_iterat : Number of iterations to look for the target entropy 0071 % 0072 % Output: 0073 % ------- 0074 % * Results : Struct variable with the following fields 0075 % 0076 % - Results(i).Image = Decoded image corresponding to the i-th value 0077 % of the target entropy vector. 0078 % - Results(i).Entropy = Entropy (in bits/pix): file_size/256^2 0079 % - Results(i).RMSE = RMSE distortion of the i-th decoded image 0080 % - Results(i).SSIM = Structural SIMilarity Index of the i-th 0081 % decoded image. 0082 % (See Wang et al. IEEE Tr. Im. Proc., 2004 0083 % for a description of this distortion measure) 0084 % - Results(i).SCIELab_exp1= Spatial CIE Lab distortion with summation exponent 0085 % equal to 1, default in S-CIELab computations. 0086 % (See Zhang & Wandell, Sig. Proc. 1998 0087 % for a description of this distortion measure) 0088 % - Results(i).SCIELab_exp2= Spatial CIE Lab distortion with summation exponent 0089 % equal to 2. (See Zhang & Wandell, Sig. Proc. 1998 0090 % for a description of this distortion 0091 % measure) 0092 % 0093 function [Results] = KeCoDe_encoder_color(Im,algorit,directorio,ficherin,entropias,N_it) 0094 warning('off','MATLAB:dispatcher:InexactMatch') 0095 Im=double(Im); 0096 if algorit==1 0097 0098 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]; 0099 Approximate_uCP=[1.3 3.1 4 4.7 5.3 5.7 6.2 6.5 7.2 7.7 8.2 8.7 9.1 9.5 9.8]; 0100 for i=1:length(entropias) 0101 if entropias(i)>max(Desired_entropy), 0102 parametro(i)=10.5; 0103 elseif entropias(i)<min(Desired_entropy), 0104 parametro(i)=1.1; 0105 else 0106 parametro(i)=interp1(Desired_entropy,Approximate_uCP,entropias(i)); 0107 end 0108 end 0109 elseif algorit==2 0110 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]; 0111 Approx_Epsilon= [1.6 0.23 0.06 0.02 0.006 0.004 0.002 0.0016 0.0009 0.0005 0.0003 0.00016 0.00017 0.00012 0.0001]; 0112 Approx_bits = [2.5 2.5 2.5 2.5 2.5 2.5 3 3.5 4.5 5 6 6.5 7 7.5 8]; 0113 for i=1:length(entropias) 0114 if entropias(i)>max(Desired_entropy), 0115 parametro(i)=0.00005; 0116 bits_in(i)=8; 0117 elseif entropias(i)<min(Desired_entropy), 0118 parametro(i)=1.9; 0119 bits_in(i)=2; 0120 else 0121 parametro(i)=interp1(Desired_entropy,Approx_Epsilon,entropias(i)); 0122 bits_in(i)=interp1(Desired_entropy,Approx_bits,entropias(i)); 0123 end 0124 end 0125 else 0126 disp('Not a valid algorithm selection') 0127 algorit=1000; 0128 end 0129 if algorit<=2 0130 normaliz=1; 0131 To=[100 0 0]; 0132 dUmax=40; 0133 dVmax=43; 0134 niveles=1; 0135 if algorit==1 0136 Results=entropy_jpeg(Im,normaliz,To,dUmax,dVmax,[parametro' parametro' parametro'],entropias,directorio,ficherin,N_it,niveles); 0137 else 0138 K=kernel2d_variance(16,1); 0139 exponente=[2 2 2]; 0140 tipo_alfa=1; 0141 Results=entropy_nl_svr(Im,normaliz,To,dUmax,dVmax,[parametro' parametro' parametro'],bits_in,K,exponente,tipo_alfa,entropias,directorio,ficherin,N_it); 0142 end 0143 end 0144