Download this file

67 lines (64 with data), 1.9 kB

 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
59
60
61
62
63
64
65
66
67
function [K, bases] = derivdirec(l, P_x, P_y, n, theta, sym_flag)
%DERIVDIREC 2D direction (steerable) derivative kernel
%
% [K, bases] = derivdirec(l, P_x, P_y, n, theta, sym_flag)
%
% returns (2l+1)x(2l+1) two dimensional (2D) nth-order derivative kernel
% rotated at cerntain direction 'theta'. The associated derivative
% kernels are MaxPol based filters
%
% Input(s):
% 'l' order of tap-length polynomial
% 'n' order of differentiation n>=0
% 'P' maximally polynomial degree controling the cutoff
% threshold at x- or y- axes.
% 'theta' steering angle
% 'sym_flag' 'true' for symbolic and 'false' for numerical
% calculation of maxpol coefficients
%
% Output(s):
% 'K' output steerable fitler
% 'bases' decomposing bases of 'K'
%
% See also DERIVSTAG, DERIVCENT, DERIVMTX
%
%
% Copyright (c) 2017 Mahdi S. Hosseini
%
% University of Toronto
% The Edward S. Rogers Sr. Department of,
% Electrical and Computer Engineering (ECE)
% Toronto, ON, M5S3G4, Canada
% Tel: +1 (416) 978 6845
% email: mahdi.hosseini@mail.utoronto.ca
K = 0;
for k = 0: n
%% lowpass derivative filter with cutoff level (P_x, P_y)
if mod(n - k, 2)
d_x = derivstag(l, P_x, -1/2, n - k, sym_flag);
d_x = [d_x, 0];
else
d_x = derivcent(l, P_x, 0, n - k, sym_flag);
d_x = d_x;
end
%
if mod(k, 2)
d_y = derivstag(l, P_y, -1/2, k, sym_flag);
d_y = [d_y, 0]';
else
d_y = derivcent(l, P_y, 0, k, sym_flag);
d_y = d_y';
end
%
%% 2D basis filter construction
bases{k+1} = [d_y * d_x];
%
%% bionomial coefficients
c(k+1) = nchoosek(n, k) * cos(theta)^(n-k) * (-sin(theta))^k;
%
%% accumulate 2D basis
K = K + c(k+1) * bases{k+1};
end
for k = 0: n
bases{k+1} = bases{k+1};
end