您的位置:首页 > 其它

Gauss Laplacian Pyramid

2017-04-07 08:58 861 查看


pyramid

Gaussian and laplacian pyramids are applying gaussian and laplacian filter in an image in cascade order with different kernel sizes of gaussian and laplacian filter.



Figure. 1 shows pyramid of image. Full image resolution is taken at level 0.

At each step up level image resolution is down sample by 2. So if starting image size is 256 X 256 at level 0 in level 1 image size will be 128 X 128.


Gaussian Pyramid :


 
Figure. 2 Gaussian Pyramid of level 2 

Figure. 2 shows the Gaussian pyramid block diagram of input image. 

1. Take input image (in_image), apply gaussian filter, output will be level 0 image. 

2. Down sample the level o image by 2, apply gaussian filter, output will be level 1 image. 

3. Down sample the level 1 image by 2, apply gaussian filter, output will be level 2 image. 

4. Similar way we can create full pyramid of gaussian.
Every level use same Gaussin filter. (If you are down sampling the image by 2 at each level, size of gassuan filter should not be changed)
Effect of down sampling the image by 2 is equivalent to increasing the bandwidth of gaussian filter by 2.
Suppose gaussuain filter cutoff frequency is F1 in 0 level if we down sample image by 2 gaussian filter cut of frequency will be 2*F1 for down sampled image.
So by down sampling the image, we are applying different sizes of gaussian in input image. That is also called multi resolution analysis.
Gaussian pyramids are used in SIFT, Surf, Gabor filters for multi resolution features extractor 

gaussian_pyramid_image. 


 
Figure. 3 shows gaussian pyramid results. Level 2 image is much blurred as compared to level 0.


Laplacian Pyramid:


 
Figure. 4 Laplacian pyramid of level 1

Suppose Level 0, level 1 and level 2 is the output of gaussian pyramid as we discussed above. Figure. 4 shows the block diagram of laplacian pyramid from gaussian pyramid. 

1. Up sample the gaussian level 1 image by 2 (level 1_2)and subtract the level 1_2 image from level 0 image, output will be laplacian of level 0. 

2. Upsample the gaussian level 2 image by 2 (level 2_2) and subtract the level 2_2 image from level 1 gaussian image , output will be laplacian of level1. 

- Laplacian pyramid try to find out the pass band frequency. 

- Suppose gaussian level 0 frequency is f1 and gaussian level 1 frequency is f2, so laplacian level 0 frequency will be f2 – f1. 

- Laplacian pyramid used many time in object detection pre processing steps. 

- It can help to compute the optical flow for large motion vector.


 
Figure .5 Laplacian pyramid results of level 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Code Start %%%%%%%%%%%%%%%

clc % clear the screen
clear all % clear all variables
close all % close all MATLAB windows

%% read Image
% set path to read image from system
ImagePath = ‘D:\DSUsers\uidp6927\image_processingCode\lena.jpg’;
img_RGB = imread(ImagePath); % read image from path
img_RGB = im2double(img_RGB); % Convert image to double precision
img_gray = rgb2gray(img_RGB); % convert image to gray
[row,col,channel] = size(img_gray); % get size of image
h_gauss = fspecial(‘gaussian’,11,1);

% apply gaussian filter to gray image
gauss_level_0 = imfilter(img_gray, h_gauss,’replicate’);
% down sample the gauss_level_0 image by 2 (resize function)
% Apply gaussian filter
gauss_level_1 = imfilter(imresize(gauss_level_0,[round(row/2),round(col/2)]), h_gauss,’replicate’);
% down sample the gauss_level_1 image by 2 (resize function)
% Apply gaussian filter
gauss_level_2 = imfilter(imresize(gauss_level_1,[round(row/4),round(col/4)]), h_gauss,’replicate’);
% down sample the gauss_level_2 image by 2 (resize function)
% Apply gaussian filter
gauss_level_3 = imfilter(imresize(gauss_level_2,[round(row/8),round(col/8)]), h_gauss,’replicate’);

% upsample the gauss_level_1 image by 2(resize function)
% subtract resized gauss_level_1 image from gauss_level_0 image
laplacian_level_0 = gauss_level_0 – imresize(gauss_level_1,[row,col]);
% upsample the gauss_level_2 image by 2(resize function)
% subtract resized gauss_level_2 image from gauss_level_1 image
laplacian_level_1 = (gauss_level_1 – imresize(gauss_level_2,[round(row/2),round(col/2)]));
% upsample the gauss_level_3 image by 2(resize function)
% subtract resized gauss_level_3 image from gauss_level_2 image
laplacian_level_2 = (gauss_level_2 – imresize(gauss_level
be35
_3,[round(row/4),round(col/4)]));

% draw all the images
subplot(2,2,1), imshow(img_gray,[])
title(‘input image’)
subplot(2,2,2), imshow(gauss_level_0,[])
title(‘gaussian pyramid level0’)
subplot(2,2,3), imshow(gauss_level_1,[])
title(‘gaussian pyramid level1’)
subplot(2,2,4), imshow(gauss_level_2,[])
title(‘gaussian pyramid level2’)

figure,
subplot(2,2,1), imshow(img_gray,[])
title(‘input image’)
subplot(2,2,2), imshow(laplacian_level_0,[])
title(‘laplacian pyramid level0’)
subplot(2,2,3), imshow(laplacian_level_1,[])
title(‘laplacian pyramid level1’)
subplot(2,2,4), imshow(laplacian_level_2,[])
title(‘laplacian pyramid level2’)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%Code End %%%%%%%%%%%%%%%%
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
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  图像增强