icontras3

PURPOSE ^

ICONTRAS3 is the inverse of CONTRAS3.

SYNOPSIS ^

function [dctf]=contras3(s,Lm,Ncuan,norm,To,DUmax,DVmax)

DESCRIPTION ^

 ICONTRAS3 is the inverse of CONTRAS3.


 CONTRAS3 allows three types of normalization:

 * Using the overall average image color (norm = 1)
 * Using the average color of each block (norm = 2)
 * Using color reference provided in To (in RGB NTSC) (norm = 3)
     For reference, the average color of the 19 analyzed images (in RGB NTSC
     uncalibrated) is To = [132 116 90] (which has a luminance of 118 cd/m2)


 The inverse is ICONTRAS3


 USE: [dctf]=icontras3(dcti,Lm,Ncuan,Norm,To,DUmax,DVmax);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % ICONTRAS3 is the inverse of CONTRAS3.
0002 %
0003 %
0004 % CONTRAS3 allows three types of normalization:
0005 %
0006 % * Using the overall average image color (norm = 1)
0007 % * Using the average color of each block (norm = 2)
0008 % * Using color reference provided in To (in RGB NTSC) (norm = 3)
0009 %     For reference, the average color of the 19 analyzed images (in RGB NTSC
0010 %     uncalibrated) is To = [132 116 90] (which has a luminance of 118 cd/m2)
0011 %
0012 %
0013 % The inverse is ICONTRAS3
0014 %
0015 %
0016 % USE: [dctf]=icontras3(dcti,Lm,Ncuan,Norm,To,DUmax,DVmax);
0017 
0018 function [dctf]=contras3(s,Lm,Ncuan,norm,To,DUmax,DVmax)
0019 
0020    ss=s;
0021    tam=size(ss);
0022 
0023    if length(tam)==3
0024       capas=tam(3);
0025    else
0026       capas=1;
0027    end
0028    tam=tam(1);
0029 
0030    lados=[tam tam];
0031 
0032    dctf=zeros(tam,tam,capas);
0033 
0034    lcuan=tam/(2^Ncuan);
0035 
0036    posai=[tam tam]/2-round(tam/2);
0037    posbd=[tam tam]/2+round(tam/2);
0038    coorcuanai=floor([(posai(1)-1)/lcuan+1 (posai(2)-1)/lcuan+1]);
0039    coorcuanbd=floor([(posbd(1)-1)/lcuan+1 (posbd(2)-1)/lcuan+1]);
0040    if coorcuanai(1)<1
0041         coorcuanai(1)=1;
0042    end
0043    if coorcuanai(2)<1
0044         coorcuanai(2)=1;
0045    end
0046    if coorcuanbd(1)>(2^Ncuan)
0047         coorcuanbd(1)=2^Ncuan;
0048    end
0049    if coorcuanai(2)>(2^Ncuan)
0050         coorcuanbd(2)=2^Ncuan;
0051    end
0052 
0053    Mrgb_yuv =[0.2990    0.5870    0.1140;-0.1726   -0.3388    0.5114;0.5114   -0.4282   -0.0832];
0054    Myuv_rgb = inv(Mrgb_yuv);
0055 
0056 if norm==1
0057 
0058     if capas==3
0059        To_yuv=[mean(mean(Lm(:,:,1))) mean(mean(Lm(:,:,2))) mean(mean(Lm(:,:,3)))];
0060        To=(Myuv_rgb*To_yuv')';
0061     else
0062        To=mean(mean(Lm));
0063        To_yuv=To;
0064     end
0065 
0066 elseif norm==2
0067     To=0;
0068 else
0069     if capas==3
0070        To_yuv=(Mrgb_yuv*To')';
0071     else
0072        To_yuv=To;
0073     end
0074 end
0075 
0076 factores_DCT_discreta=2*ones(lcuan,lcuan)/lcuan;
0077 factores_DCT_discreta(1,:)=sqrt(2)*ones(1,lcuan)/lcuan;
0078 factores_DCT_discreta(:,1)=sqrt(2)*ones(lcuan,1)/lcuan;
0079 factores_DCT_discreta(1,1)=1/lcuan;
0080 
0081 dctf=ss;
0082 
0083 for i=1:capas
0084 
0085     s=ss(:,:,i);
0086     for ii=coorcuanai(1):coorcuanbd(1)
0087         for jj=coorcuanai(2):coorcuanbd(2)
0088 
0089             iii=(ii-1)*lcuan+ceil(lcuan/2);
0090             jjj=(jj-1)*lcuan+ceil(lcuan/2);
0091             blo=sacasub(s,[iii jjj],[lcuan lcuan],0);
0092 
0093             if i==1
0094                 if norm==1
0095                     contraste=blo;
0096                     deltaT=contraste*To_yuv(1);
0097                     blo=deltaT./factores_DCT_discreta;
0098                     blo(1,1)=Lm(ii,jj,i)./factores_DCT_discreta(1,1);
0099                 elseif norm==2
0100                     contraste=blo;
0101                     To=Lm(ii,jj,i);
0102                     deltaT=contraste*To;
0103                     blo=deltaT./factores_DCT_discreta;
0104                     blo(1,1)=Lm(ii,jj,i)./factores_DCT_discreta(1,1);
0105                 else
0106                     contraste=blo;
0107                     deltaT=contraste*To_yuv(1);
0108                     blo=deltaT./factores_DCT_discreta;
0109                     blo(1,1)=Lm(ii,jj,i)./factores_DCT_discreta(1,1);
0110                 end
0111             else
0112                 if norm==1
0113                     if i==2
0114                        W=To';
0115                        YW=To_yuv(1);
0116                        e1=(Myuv_rgb*[0;DUmax;0]+W)/YW;
0117                        e2=2*W/YW-e1;
0118                        div=Mrgb_yuv*(e1-e2);
0119                        div=div(2);
0120 
0121                     else
0122                        W=To';
0123                        YW=To_yuv(1);
0124                        e1=(Myuv_rgb*[0;0;DVmax]+W)/YW;
0125                        e2=2*W/YW-e1;
0126                        div=Mrgb_yuv*(e1-e2);
0127                        div=div(3);
0128 
0129                     end
0130                     contraste=blo;
0131                     deltaT=(YW/2)*div*contraste;
0132                     blo=deltaT./factores_DCT_discreta;
0133                     blo(1,1)=Lm(ii,jj,i)./factores_DCT_discreta(1,1);
0134                 elseif norm==2
0135                     To_yuv=[Lm(ii,jj,1);Lm(ii,jj,2);Lm(ii,jj,3)];
0136                     To=Myuv_rgb*To_yuv;
0137                     if i==2
0138                        W=To;
0139                        YW=To_yuv(1);
0140                        e1=(Myuv_rgb*[0;DUmax;0]+W)/YW;
0141                        e2=2*W/YW-e1;
0142                        div=Mrgb_yuv*(e1-e2);
0143                        div=div(2);
0144                     else
0145                        W=To;
0146                        YW=To_yuv(1);
0147                        e1=(Myuv_rgb*[0;0;DVmax]+W)/YW;
0148                        e2=2*W/YW-e1;
0149                        div=Mrgb_yuv*(e1-e2);
0150                        div=div(3);
0151                     end
0152                     contraste=blo;
0153                     deltaT=(YW/2)*div*contraste;
0154                     blo=deltaT./factores_DCT_discreta;
0155                     blo(1,1)=Lm(ii,jj,i)./factores_DCT_discreta(1,1);
0156                 else
0157                     if i==2
0158                        W=To';
0159                        YW=To_yuv(1);
0160                        e1=(Myuv_rgb*[0;DUmax;0]+W)/YW;
0161                        e2=2*W/YW-e1;
0162                        div=Mrgb_yuv*(e1-e2);
0163                        div=div(2);
0164                     else
0165                        W=To';
0166                        YW=To_yuv(1);
0167                        e1=(Myuv_rgb*[0;0;DVmax]+W)/YW;
0168                        e2=2*W/YW-e1;
0169                        div=Mrgb_yuv*(e1-e2);
0170                        div=div(3);
0171                     end
0172                     contraste=blo;
0173                     deltaT=(YW/2)*div*contraste;
0174                     blo=deltaT./factores_DCT_discreta;
0175                     blo(1,1)=Lm(ii,jj,i)./factores_DCT_discreta(1,1);
0176                 end
0177             end
0178             dctf(:,:,i)=metesub(dctf(:,:,i),[iii jjj],blo);
0179         end
0180     end
0181 end

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