IMDPCM invierts the image codification given a spatial DPCM estimating each pixel given a lineal combination of the neighbours (in a neighbouthood of N^2 size). / N \ est(I([i,j]))= round | sum w(d)*I([i,j]-d) | \ d=1 / It gives back the prediction error for each point: e([i,j])=I(i,j)-est(I([i,j])) Given this error, the original signal can be reconstructed using IIMDPCM USE: e=imdpcm(I,[w(1) w(2) w(3)...],valor_relleno);
0001 % IMDPCM invierts the image codification given a spatial DPCM 0002 % estimating each pixel given a lineal combination of the neighbours 0003 % (in a neighbouthood of N^2 size). 0004 % 0005 % / N \ 0006 % est(I([i,j]))= round | sum w(d)*I([i,j]-d) | 0007 % \ d=1 / 0008 % 0009 % It gives back the prediction error for each point: 0010 % 0011 % e([i,j])=I(i,j)-est(I([i,j])) 0012 % 0013 % Given this error, the original signal can be reconstructed using IIMDPCM 0014 % 0015 % USE: e=imdpcm(I,[w(1) w(2) w(3)...],valor_relleno); 0016 0017 function e=imdpcm(I,w,val_relleno) 0018 0019 l=length(w); 0020 s=size(I); 0021 a=val_relleno*ones(l,s(2)+2*l); 0022 i=val_relleno*ones(s(1),l); 0023 d=val_relleno*ones(s(1),l); 0024 b=val_relleno*ones(l,s(2)+2*l); 0025 I=[a;i I d;b]; 0026 estI=I; 0027 e=I; 0028 0029 W=simrev([w(1) w]); 0030 W(1,1)=0; 0031 W=rot90(W,2); 0032 W=W/sum(sum(W)); 0033 0034 for i=l+1:s(1)+l 0035 0036 for j=l+1:s(2)+l 0037 bloc=I(i-l:i,j-l:j); 0038 estI(i,j)=round(sum(sum(W.*bloc))); 0039 e(i,j)=I(i,j)-estI(i,j); 0040 end 0041 end 0042 e=sacasub(e,[s(1)/2+l s(2)/2+l],[s(1) s(2)],0);