qreredct_v2

PURPOSE ^

QREREDCT (uniform) quantization of the linear reretransformada

SYNOPSIS ^

function [xdct2,dctq,imq]=qreredct_v2(imag,B,trayfich,M)

DESCRIPTION ^

 QREREDCT  (uniform) quantization of the linear reretransformada
 of the blocks of the image that are passed, M may be a
 scalar or vector giving the maximum in each coefficient
 If it is a scalar, the same maximum gets on all coef.
 To get the maximum with those obtained in sacaesta, use maxcoef
 (H2 disregarding signs)

 USE: [imq,codq,E,Hi]=qreredct(im,B,'c:\tmp\estarere',maximo_r'');
 Hi: Entropy computed earliest form, E: entropy calculated according e2 entroprova: all blocks

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % QREREDCT  (uniform) quantization of the linear reretransformada
0002 % of the blocks of the image that are passed, M may be a
0003 % scalar or vector giving the maximum in each coefficient
0004 % If it is a scalar, the same maximum gets on all coef.
0005 % To get the maximum with those obtained in sacaesta, use maxcoef
0006 % (H2 disregarding signs)
0007 %
0008 % USE: [imq,codq,E,Hi]=qreredct(im,B,'c:\tmp\estarere',maximo_r'');
0009 % Hi: Entropy computed earliest form, E: entropy calculated according e2 entroprova: all blocks
0010 
0011 function [xdct2,dctq,imq]=qreredct_v2(imag,B,trayfich,M)
0012 
0013 tam=size(imag);
0014 
0015 load(trayfich);
0016 
0017 resol=4;
0018 H=0;
0019 Hi=0;
0020 
0021 tamM=size(M);
0022 if tamM==[1 1]
0023     M=M*ones(256,1);
0024 end
0025 
0026 tam=tam(1);
0027 pto=[tam tam]/2;
0028 lados=[tam tam];
0029 lcuan=tam/(2^resol);
0030 posai=pto-round(lados/2);
0031 posbd=pto+round(lados/2);
0032 coorcuanai=floor([(posai(1)-1)/lcuan+1 (posai(2)-1)/lcuan+1]);
0033 coorcuanbd=floor([(posbd(1)-1)/lcuan+1 (posbd(2)-1)/lcuan+1]);
0034 
0035 if coorcuanai(1)<1
0036     coorcuanai(1)=1;
0037 end
0038 if coorcuanai(2)<1
0039     coorcuanai(2)=1;
0040 end
0041 if coorcuanbd(1)>(2^resol)
0042     coorcuanbd(1)=2^resol;
0043 end
0044 if coorcuanai(2)>(2^resol)
0045     coorcuanbd(2)=2^resol;
0046 end
0047 
0048 adctfglob=zeros(size(imag));
0049 
0050 xdct2=dct2r(imag,resol);
0051 [xdctf,xLm]=contrast_2(xdct2,resol,[1 0]);
0052 adct=abs(xdctf);
0053 sdct=sign(xdct2);
0054 sdct(sdct==0)=1;
0055 
0056 DC = xLm*16;
0057 L = V2'*grad;
0058 
0059 dctq=zeros(tam,tam);
0060 codq=dctq;
0061 invgrad=inv(grad);
0062 
0063 codigazo = zeros(256,256);
0064 bloquecito = 1;
0065 
0066 for ii=coorcuanai(1):coorcuanbd(1)
0067 
0068     for jj=coorcuanai(2):coorcuanbd(2)
0069 
0070         iii=(ii-1)*lcuan+ceil(lcuan/2);
0071         jjj=(jj-1)*lcuan+ceil(lcuan/2);
0072         cub=sacasub(adct,[iii jjj],[lcuan lcuan],0);
0073         zcub=zigzag(cub);
0074         tzcub=L*(zcub)+consta;
0075 
0076         cod=round(2^B*tzcub./M);
0077 
0078         cod(1)=0;
0079 
0080         aux2=((cod==Inf)|(cod==-Inf));
0081         cod(aux2)=0;
0082 
0083         rrc=cod.*M/(2^B);
0084 
0085         signo1=zigzag(sacasub(sdct,[iii jjj],[lcuan lcuan],0));
0086 
0087         codigo = signo1.*rrc;
0088         codigazo(bloquecito,:) = codigo;
0089 
0090         irrq=signo1.*adctm+signo1.*(invgrad*V2*rrc);
0091 
0092         irrq=dezigzag(irrq);
0093 
0094         dc(2:lcuan,1)=irrq(2:lcuan,1)*DC(ii,jj)/2;
0095         dc(1,2:lcuan)=irrq(1,2:lcuan)*DC(ii,jj)/2;
0096         dc(2:lcuan,2:lcuan)=irrq(2:lcuan,2:lcuan)*DC(ii,jj)/4;
0097         dc(1,1)=DC(ii,jj);
0098 
0099         dctq=metesub(dctq,[iii jjj],dc);
0100         codq=metesub(codq,[iii jjj],dezigzag(cod));
0101 
0102         bloquecito = bloquecito + 1;
0103     end
0104 end
0105 
0106 imq=idct2r(dctq,resol);
0107 
0108 Hi=Hi/(256*256);
0109 
0110 e2=0;
0111 n_im=1;
0112 f=linspace(0,32,16);
0113 F=repmat(simrev(f),[16 16*n_im]);
0114 for i=1:length(f)
0115     if i==1
0116         m0=(F==f(i));
0117         mue1=codq(m0);
0118 
0119     else
0120         m0=(F>f(i-1) & F<=f(i));
0121 
0122         mue1=codq(m0);
0123         e2=e2+sum(sum(m0(1:16,1:16)))*entropiv(mue1);
0124     end
0125 
0126 end
0127 
0128 E=e2/255;
0129

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