-
Notifications
You must be signed in to change notification settings - Fork 2
/
udwt_1D_rec.m
80 lines (70 loc) · 1.94 KB
/
udwt_1D_rec.m
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
%
% UDWR undecimated wavelet decomposition
%
% RIC = udwt(H,V,D,L,NLIV,FILTER_TYPE,LINEARPHASE_TYPE)
%
% H, V, D, [L]= horizontal, diagonal, diagonal lowpass wavelets
% coefficients and approximation
% NLIV = level number
% FILTER_TYPE = wavelet filter type
% LINEARPHASE_TYPE = linear phase flag
%
% RIC = reconstructed image
%
function RIC = udwt_1D_rec( H, nliv, FILTER_TYPE, LINEARPHASE_FLAG, L)
DISPLAY_FLAG = 0;
%
% Inizializzazioni
%
[M N] = size(H); % Dimensioni immagini
%
%
[Lo_D,Hi_D] = wfilters(FILTER_TYPE,'d');
Lo_D = Lo_D/sqrt(2);
Hi_D = Hi_D/sqrt(2);
[Lo_R,Hi_R] = wfilters(FILTER_TYPE,'r'); % FILTRI di RICOSTRUZIONE
Lo_R = Lo_R/sqrt(2);
Hi_R = Hi_R/sqrt(2);
% calcolo filtro equivalente
for liv = 1:nliv
lp_eq = 1;
lp_eq_r = 1;
for k = 0:liv-2
lp_eq = conv(Lo_D, upsamp2(lp_eq, 2));
lp_eq_r = conv(Lo_R, upsamp2(lp_eq_r,2));
end
lp_filt = conv(lp_eq, upsamp2(Lo_D, 2^(liv-1)));
hp_filt = conv(lp_eq, upsamp2(Hi_D, 2^(liv-1)));
lp_filt_r = conv(lp_eq_r, upsamp2(Lo_R,2^(liv-1)));
hp_filt_r = conv(lp_eq_r, upsamp2(Hi_R,2^(liv-1)));
Nlp = size(lp_filt,2);
Nhp = size(hp_filt,2);
Nlpr = size(lp_filt_r,2);
Nhpr = size(hp_filt_r,2);
[maxlp,delay_lowpass] = max(abs(lp_filt));
[maxlp,delay_highpass] = max(abs(hp_filt));
delay_lowpass = delay_lowpass - 1;
delay_highpass = delay_highpass - 1;
end
if DISPLAY_FLAG == 1
figure(1)
plot(lp_filt)
pause
plot(hp_filt)
pause
[Hl W] = freqz(lp_filt,1,512);
plot(W,abs(Hl))
pause
[Hh W] = freqz(hp_filt,1,512);
plot(W,abs(Hh))
pause
end
% ricostruisco con wavelet non decimata
H = filtro1dsprt(H, hp_filt_r, Nhp - delay_highpass - 1, LINEARPHASE_FLAG, -1);
RIC = H
if nargin == 5
L = filtro1dsprt(L, lp_filt_r, Nlp - delay_lowpass - 1, LINEARPHASE_FLAG, 1)
RIC = RIC + L;
end
% Sommo le sottobande
return