-
Notifications
You must be signed in to change notification settings - Fork 227
/
test_laplacian_do.m
44 lines (39 loc) · 1.11 KB
/
test_laplacian_do.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
% Demo of the Laplacian pyramid functions
n = 256;
M = load_image('lena', n);
% Laplacian decomposition using 9/7 filters and 5 levels
pfilt = '9/7'; J = 5;
MP = perform_pyramid_transform_do(M, pfilt, J);
% Wavelet transform
Jmin = 4;
options.wavelet_type = 'biorthogonal_swapped';
options.wavelet_vm = 4;
MW = perform_wavelet_transform(M, Jmin, +1, options);
% Display output of the pyramid
figure(1)
colormap(gray);
nr = floor(sqrt(J+1));
nc = ceil((J+1)/nr);
for l = 1:J+1
subplot(nr, nc, l);
imagesc(MP{l});
axis image; axis off;
end
% Reconstruction
m = floor( 0.05*n^2 );
MPt = keep_biggest(MP, m);
MWt = keep_biggest(MW, m);
M1 = perform_pyramid_transform_do(MPt, pfilt);
M2 = perform_wavelet_transform(MWt, Jmin, -1, options);
% Show perfect reconstruction
figure(2);
colormap gray;
subplot(1,3,1), imagesc(M);
axis image; axis off;
title('Original image');
subplot(1,3,2), imagesc(M1);
axis image; axis off;
title(sprintf('Pyramid, PSNR=%.2f dB', PSNR(M, M1)))
subplot(1,3,3), imagesc(M2);
axis image; axis off;
title(sprintf('Wavelet, PSNR=%.2f dB', PSNR(M, M2)))