image = readpgm('mars.pgm'); A = image(1,1:382)'; W=ftm(382); H_0 = H0(382); H_1 = H1(382); h_0= W*H_0; h_1=W*H_1; Afreq=W'*A; Bf= H_1.*Afreq; Bs = W*Bf; Cf= H_0.*Afreq; Cs= W*Cf; Ds=downsample(Bs); new_W = ftm(191); Df= new_W'*Ds; Es=downsample(Cs); Ef= new_W'*Es; Fs=upsample(Ds); Ff= W'*Fs; Gs=upsample(Es); Gf = W'*Gs; Hf = H_1.*Ff; Hs= W*Hf; If = H_0.*Gf; Is= W*If; Js= Hs+Is; Jf= Hf+If; %Js= W*Jf; plot(1:382,A,'r-',1:382,real(Js),'b:'); legend('orig and real Js');