Gaussianpyramid: used for downsampling, the main image pyramid Laplacianpyramid: It is used to reconstruct the unsampled image of the upper layer from the lower layer of the pyramid. In digital image processing, it is also known as residual prediction, which can restore the image to the maximum extent and be used together with the Gaussian pyramid. A brief difference between the two: the Gauss pyramid is used to sample an image downward, while the Laplace Pyramid is used to sample an image upward from the bottom of the pyramid. (1) To generate the I +1 layer of the Gaussian pyramid from the I layer of the pyramid (we denote the I +1 layer as G_i+1), we first convolve with the Gauss check G_1, and then delete all even rows and even columns. Of course, the area of the new image will become a quarter of the original image. The entire pyramid is produced by performing the above procedure on the input image G_0. As the image moves up the pyramid, its size and resolution decrease. In order to obtain the pyramid image with hierarchy G_i+1, we adopt the following method: <1> Gaussian kernel convolution of image G_i <2> Remove all even rows and columns to get the image of G_i+1. Obviously, the resulting image is only a quarter of the original image. By iterating through the above steps on the input image G_i(the original image) you get the entire pyramid. At the same time, we can also see that downward sampling will gradually lose the information of the image. If you want to enlarge the image, you need to obtain it through upward sampling operation, which is as follows: <1> Enlarge the image twice as large as the original in each direction, and fill the newly added rows and columns with 0. <2> Convolve the enlarged image with the previous same kernel (multiplied by 4) to obtain the approximate value of “newly added pixels”, which is the enlarged image, but will be found to be fuzzy compared with the original image. Because some information has been lost in the process of scaling


inputPath ='D:/ CVPR/task 1/ experiment 1/ ';
filename =[inputPath 'test.jpeg'];
I = im2double(imread(filename));
if size(I,3) = =3I=rgb2gray(I); End % gauss_pyr= gauss_PYr (I,5);
 
for i=1:length(gauss_pyr) figure; imshow(gauss_pyr{i}); endCopy the code
function pyr = gauss_pyramid(I,nlev)
 
pyr = cell(nlev,1);
pyr{1} = I;
G_LOWER = I;
 
f = [.05.25..4..25...05];  
f = f'*f; For l = 2:nlev G_LOWER=G_LOWER(1:2:size(G_LOWER,1)-1,1:2:size(G_LOWER,2)-1); %downsample pyr{l}=imfilter(G_LOWER,f,'replicate'); end endCopy the code