1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
;***************************
pro IUWT, X, D, W
Sig_in=double(X)
W=fltarr(size(X,/dimension),D+1);
h=float([1, 4, 6, 4, 1])/16.0
index=[0,1,2,3,4]
n=5
K=h
cj=X
for i=0,D-1 do begin
ck=convol(cj,k, /CENTER, /EDGE_WRAP)
W(*,i)=cj-ck
cj=ck
n=n*2-1
print, n
k= fltarr(n)
index=index*2
k[index]=h
endfor
W(*,D)=cj
end
;********** 2D functions*************
pro IUWT2D, X, D, W
X=double(X)
s=size(X)
W=dblarr(s(1),s(2),D+1);
h=double([1, 4, 6, 4, 1])/16.0
index=[0,1,2,3,4]
k=h
n=5
cj=X
for i=0,D-1 do begin
tmp=convol(cj,k, /CENTER, /EDGE_WRAP)
ck=convol(tmp,transpose(k), /CENTER, /EDGE_WRAP)
W(*,*,i)=cj-ck
cj=ck
n=n*2-1
index=index*2
k=fltarr(n)
k[index]=h
endfor
W(*,*,D)=cj
end
;*********************** 1D/2D Reconstruction *********************
pro R_IUWT, W, Y
;Inverse Isotropic Undecimated Undecimated Wavelet Transform
s=size(W)
Y=total(W,s(0));
end
;********* test programs 1D/2D IUWT+R_IUWT
;=========================================
pro test1D, scales
n=100
x=fltarr(n)
x(50)=16
IUWT, x,scales,w
R_IUWT, w,y
!P.MULTI=[0,scales+3,1]
for i=0, scales do begin
plot, w(*,i)
endfor
plot,x
plot,y
print, total(x-y)
end
;=========================================
pro test2D, scales
x=read_image('Enstein.jpg')
IUWT2D, x, scales, W
R_IUWT, W,y
s=size(x)
WINDOW, scales+4, XSIZE = (scales/2+2)*s(1), YSIZE = 2*s(2)
for i=0, scales do begin
tv, W(*,*,i),i
endfor
tv,x,scales+1
tv,y,scales+2
print, total(total(x-y),1)
end
;;========Main program
test1d,4
test2d,5
end |