-
Notifications
You must be signed in to change notification settings - Fork 13
/
gen_dgauss.m
50 lines (39 loc) · 1.12 KB
/
gen_dgauss.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
47
48
49
50
%
% take gradient for gaussian template
%
% Created by Rui Zhao, on May 20, 2013.
% This code is release under BSD license,
% any problem please contact Rui Zhao [email protected]
%
% Please cite as
% Rui Zhao, Wanli Ouyang, and Xiaogang Wang. Unsupervised Salience Learning
% for Person Re-identification. In IEEE Conference of Computer Vision and
% Pattern Recognition (CVPR), 2013.
%
function [GX,GY]=gen_dgauss(sigma)
% laplacian of size sigma
%f_wid = 4 * floor(sigma);
%G = normpdf(-f_wid:f_wid,0,sigma);
%G = G' * G;
if(nargin < 1)
sigma = 1;
end
G = gen_gauss(sigma);
[GX,GY] = gradient(G);
GX = GX * 2 ./ sum(sum(abs(GX)));
GY = GY * 2 ./ sum(sum(abs(GY)));
function G=gen_gauss(sigma)
if all(size(sigma)==[1, 1])
% isotropic gaussian
f_wid = 4 * ceil(sigma) + 1;
G = fspecial('gaussian', f_wid, sigma);
% G = normpdf(-f_wid:f_wid,0,sigma);
% G = G' * G;
else
% anisotropic gaussian
f_wid_x = 2 * ceil(sigma(1)) + 1;
f_wid_y = 2 * ceil(sigma(2)) + 1;
G_x = normpdf(-f_wid_x:f_wid_x,0,sigma(1));
G_y = normpdf(-f_wid_y:f_wid_y,0,sigma(2));
G = G_y' * G_x;
end