Professional Documents
Culture Documents
Pyramid Method and Wavelet
Pyramid Method and Wavelet
WAHYU RAHMANIAR
102521604
Computer Project 2: Pyramid method and Wavelet
1. Pyramid methods:
(1) Gaussian pyramid.
dir *.lan
fid=fopen('montana.lan','r');
fseek(fid,128,-1);
A=fread(fid,[512*7 512],'uint8');
B=A(512*3+1:512*4,:)';
imagesc(B)
title('paris')
C=ones(size(B));
% Gaussian Pyramid
w=[.05 .25 .4 .25 .05];
% Reduce
W=w'*w;
D=conv2(B,W,'same')./conv2(C,W,'same');
G1=D(2:2:end,2:2:end);
figure
imagesc(G1)
title('reduce')
colormap(gray)
% Expand
F=zeros(512);
F(2:2:end,2:2:end)=G1;
imagesc(F)
title('expand1')
colormap(gray)
H=4*conv2(F,W,'same')./conv2(C,W,'same');
figure
imagesc(H)
title('expand2')
colormap(gray)
figure
imagesc(B-H)
title('expand3')
colormap(gray)
Bandpass, rather than lowpass, images are required for many purposes. These may be
obtained by subtracting each Gaussian (lowpass) pyramid level from the nextlower level
in the pyramid. Because these levels differ in their sample density it is necessary to
interpolate new sample values between those in a given level before that level is
subtracted from the next-lower level. Interpolation can be achieved by EXPAND
operation.
Gi+1 (x,y) = EXPAND (Gi(x,y))
The expand operation is defined as follows:
By repeating these steps several times a sequence of images expand 1, 2, and 3 are
obtained. Levels of the Gaussian pyramid expanded to the size of the original image. The
effects of lowpass filtering are now clearly apparent. The expand operation doubles the
size of the image with each iteration, so that Gi,1, is the size of Gi,1, and Gi,1 is the same
size as that of the original image. Examples of expanded Gaussian pyramid levels are
shown in below:
The Laplacian pyramid can thus be used to represent images as a series of band-pass
filtered images, each sampled at successively sparser densities. The levels of the
Laplacian pyramid can be specified in terms of the lowpass pyramid levels as follows:
Li = Gi - EXPAND (Gi(x,y))
= Gi Gi+1
Just as the value of each node in the Gaussian pyramid could have been obtained
directly by convolving a Gaussian-like equivalent weighting function with the original
image, each value of this bandpass pyramid could be obtained by convolving a difference
of two Gaussians with the original image, this six levels are shown in the picture below:
As with the Fourier transform, pyramid code elements represent pattern components
that are restricted in the spatial-frequency domain. But unlike the Fourier transform,
pyramid code elements are also restricted to local regions in the spatial domain. Spatial as
well as spatial-frequency localization can be critical in the analysis of images that contain
multiple objects so that code elements will tend to represent characteristics of single
objects rather than confound the characteristics of many objects.
The coarsest scale of the Laplacian pyramid is the same as the Gaussian pyramid.
Each of the finer layers are the difference between a layer of Gaussian pyramid and a
prediction obtained by up-sampling the next coarsest layer of the Gaussian pyramid.
2. Wavelet
fid=fopen('montana.lan','r');
fseek(fid,128,-1);
A=fread(fid,[512*7 512],'uint8');
B=A(512*3+1:512*4,:)';
% Harr Wavelet (Compare to Box pyramid)
figure
subplot(1,2,1)
% low-pass in horizontal
C1=(B(:,1:2:end)+B(:,2:2:end))/2;
imagesc(C1)
title('lowpass')
subplot(1,2,2)
% high-pass in horizontal
C2=(B(:,1:2:end)-B(:,2:2:end))/2;
imagesc(C2)
title('highpass')
The point of doing Haar wavelet transform is that areas of the original matrix that
contain little variation will end up as zero elements in the transformed matrix. A matrix is
considered sparse if it has a high proportion of zero entries. Sparse matrices take much
less memory to store.
The first step of denoising is the application of filters. C1 denotes the low pass filter,
while C2 denotes the high pass filter, like the picture below:
Thus, the low pass filter computes averages while the high pass filter accomplishes
differencing. The process of differencing detects the noise in the signal. If some detail
coefficients are small compared to the others, making them zero will not alter the signal
too much. If the noise is located in these areas of the signal, denoising will have a
positive effect on the signal.
This picture below show the low pass filter from low pass and high pass image before,
and the high pass from from low pass and high pass image before.
Then do the same, low pass (C1) and high pass (C2) filter from the low pass image
C11 and high pass image C22.
Then we do the same filter like Wavelet image, but using Gaussian pyramid low pass
filter (Dl) and high pass filter (Dh) like the picture below:
Using Gaussian pyramid we get darker image for HL and LH, but brighter image for
LL and HH. The Gaussian pyramid result is much better than the Wavelet result. The
result in Gaussian is more detail and we can see the edge of the image, but in Wavelet,
the result in not clear enough to detect the edge. Images with different focal lengths will
have different image regions in focus. Images with different shutter speeds may have
different contrast and luminance levels in different regions.