forked from phoenix104104/LapSRN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bilinear_kernel.m
47 lines (39 loc) · 1.28 KB
/
bilinear_kernel.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 f = bilinear_kernel(k, numGroups, numClasses)
% -------------------------------------------------------------------------
% Description:
% create bilinear interpolation kernel for the convt (deconv) layer
%
% Input:
% - k : kernel size k x k
% - numGroups : number of filter groups convt layer
% - numClasses : number of input channels
%
% Output:
% - f : bilinear filter
%
% Citation:
% Deep Laplacian Pyramid Networks for Fast and Accurate Super-Resolution
% Wei-Sheng Lai, Jia-Bin Huang, Narendra Ahuja, and Ming-Hsuan Yang
% IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017
%
% Contact:
% Wei-Sheng Lai
% University of California, Merced
% -------------------------------------------------------------------------
factor = floor((k + 1) / 2);
if rem(k, 2) == 1
center = factor;
else
center = factor + 0.5;
end
C = 1:k;
f = zeros(k, k, numGroups, numClasses);
for i = 1:numGroups
for j = 1:numClasses
f(:, :, i, j) = ...
(ones(1, k) - abs(C - center) ./ factor)' ...
* (ones(1, k) - abs(C - center) ./ factor);
end
end
end