forked from sidney001/image_pairs_deblur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGscale.m
46 lines (41 loc) · 1.31 KB
/
Gscale.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
45
46
function Nimg = Gscale(img,levels,gsize,sigma)
%
% Function to generate a gaussian-pyramid for the given input image
%
% Input:
% img: input image-matrix grayscale
% levels: number of levels of the pyramid
% gsize: size of the gaussian kernel [w h] ([5 5] normally provides a smooth output)
% sigma: sigma for gaussian kernel
% Output:
% Nimg: is a struct consisting of images from each level
% : Nimg.img;
% Usage:
% im = imread('cameraman.tif');
% Nimg = Gscale(im,3,[5 5],1.6);
% i = 2; %select a level
% figure; imshow(Nimg(i).img);
%
% Author: Pranam Janney Date: 24th July 2006 15:39
% Email: [email protected]
%
% Revised Version 1.0.1 Date: 04th August 2006, 10:50
%
%guassian filter with a sigma
g = fspecial('gaussian',gsize,sigma);
%pyramid
for i = 1:levels
if i == 1
%im = imfilter(img,g,'conv');
Nimg(i).img = img;
elseif size(Nimg(i-1).img,1) >= 32 && size(Nimg(i-1).img,2) >= 32
%perform guassian filtering
im = imfilter(Nimg(i-1).img,g,'conv');
%perform downsampling (horizontal)
Nimg(i).img = im(1:2:size(Nimg(i-1).img,1),1:2:size(Nimg(i-1).img,2));
%store it in a struct format
else
break;
end
end
%End