forked from mathisonian/eecs442-finalproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgistGabor.m
46 lines (42 loc) · 960 Bytes
/
gistGabor.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 g = gistGabor(img, w, G)
%
% Input:
% img = input image (it can be a block: [nrows, ncols, c, Nimages])
% w = number of windows (w*w)
% G = precomputed transfer functions
%
% Output:
% g: are the global features = [Nfeatures Nimages],
% Nfeatures = w*w*Nfilters*c
if ndims(img)==2
c = 1;
N = 1;
end
if ndims(img)==3
[nrows ncols c] = size(img);
N = c;
end
if ndims(img)==4
[nrows ncols c N] = size(img);
img = reshape(img, [nrows ncols c*N]);
N = c*N;
end
[n n Nfilters] = size(G);
W = w*w;
g = zeros([W*Nfilters N]);
% size(g)
img = single(fft2(img));
k=0;
for n = 1:Nfilters
ig = abs(ifft2(img.*repmat(G(:,:,n), [1 1 N])));
v = downN(ig, w);
g(k+1:k+W,:) = reshape(v, [W N]);
k = k + W;
drawnow
end
if c == 3
% If the input was a color image, then reshape 'g' so that one column
% is one images output:
g = reshape(g, [size(g,1)*3 size(g,2)/3]);
end
end