Downsample
1)对图像G_i进行高斯内核卷积
2)将所有偶数行和列去除
Upsample
1)将图像在每个方向扩大为原来的两倍,新增的行和列以0填充
2)放大后的图像卷积,获得 “新增像素”的近似值

clear
clc
I = im2double(imread('1.png'));
I=rgb2gray(I);
N = 4; % layer
f = [.05, .25, .4, .25, .05]; % filter
f = f'*f;
G = cell(N,1);
G{1} = I;
for n = 2 : N
t = imfilter(G{n-1}, f, 'conv', 'same', 'replicate');
G{n} = t(1:2:end, 1:2:end); % 下采样
end
L = cell(N,1);
L{N} = G{N};
for n = 1 : N-1
t = imresize(G{n+1}, 2, 'bicubic');% 双上线性插值
%t = zeros(2*size(G{n+1}));
%t(1:2:end, 1:2:end) = G{n+1};
%t(2:2:end, 2:2:end) = G{n+1};
%t(1:2:end, 2:2:end) = G{n+1};
%t(2:2:end, 1:2:end) = G{n+1};% 上采样
I = imfilter(t, f, 'conv', 'same', 'replicate');
L{n} = G{n} - I;
end
%figure;
for n = 1 : N
figure(n);
%subplot(2,N,n)
imshow(G{n});
end
for n = 1 : N
figure(n+N);
%subplot(2,N,n+N)
imshow(L{n});
end