-
Notifications
You must be signed in to change notification settings - Fork 2
/
LFDemoBasicFiltGantry.m
136 lines (123 loc) · 4.51 KB
/
LFDemoBasicFiltGantry.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
% LFDemoBasicFiltGantry - demonstrate basic filters on stanford-style gantry light fields
%
% Generates and displays a set of filtered light field images as separate figures. Demonstrates
% the shift sum filter and 4D planar and 4D hyperfan linear filters.
%
% Before running this you must download sample light fields from the stanford light field archive.
% Run the demo from the top of the stanford light fields folder. Please see the accompanying documentation for
% more information.
%
% To change input light fields, uncomment the appropriate line below.
% Part of LF Toolbox v0.4 released 12-Feb-2015
% Copyright (c) 2013-2015 Donald G. Dansereau
clearvars
%---Tweakables---
UVLimit = 300; % Light fields get scaled to this size in u,v
InPathPattern = '%s/rectified'; % Pattern for where the light fields are unzipped
% Select an input light field from the list below
% InFile: Which of the Stanford lightfields to load
% SFlip: Some of the light fields are of a different "handedness", and need to be flipped in s
% InFile = 'Amethyst'; SFlip = true;
% InFile = 'Bracelet'; SFlip = false;
% InFile = 'Bulldozer'; SFlip = true;
% InFile = 'Bunny'; SFlip = true;
% InFile = 'Chess'; SFlip = true;
% InFile = 'Eucalyptus'; SFlip = true;
% InFile = 'JellyBeans'; SFlip = true;
InFile = 'LegoKnights'; SFlip = false;
% InFile = 'Tarot_Coarse'; SFlip = false;
% InFile = 'Tarot_Fine'; SFlip = false;
% InFile = 'Treasure'; SFlip = true;
% InFile = 'Truck'; SFlip = true;
%- Params for linear filters
% These must be tuned to conform to the characteristics of the light field
ShiftSumSlope1 = -0.6 * UVLimit/400;
ShiftSumSlope2 = 0;
PlanarSlope = 0;
PlanarBW = 0.06;
HyperfanSlope1 = 0;
HyperfanSlope2 = 2;
HyperfanBW = 0.035;
FiltOptions = [];
%---Load the light field---
FullPath = sprintf(InPathPattern, InFile);
fprintf('%s : ', FullPath);
FullPath = 'C:\Users\Mikael Le Pendu\Desktop\noisy/';
LF = LFReadGantryArray(FullPath, struct('UVLimit', UVLimit) );
LFSize = size(LF);
if( SFlip ) % Some of the light fields are of a different "handedness", and need to be flipped in s
LF = LF(:,end:-1:1,:,:,:);
end
CurFigure = 1;
LFFigure(CurFigure);
CurFigure = CurFigure + 1;
LFDisp(LF);
axis image off
truesize
title('Input');
drawnow
%---Demonstrate shift sum filter---
for( Slope = [ShiftSumSlope1, ShiftSumSlope2] )
fprintf('Applying shift sum filter');
[ShiftImg, FiltOptionsOut] = LFFiltShiftSum( LF, Slope );
fprintf(' Done\n');
FiltOptionsOut
LFFigure(CurFigure);
CurFigure = CurFigure + 1;
LFDisp(ShiftImg);
axis image off
truesize
title(sprintf('Shift sum filter, slope %.3g', Slope));
drawnow
end
%---Demonstrate 2D line filter---
fprintf('Building 2D frequency line... ');
Htv = LFBuild2DFreqLine( LFSize([1,3]), PlanarSlope, PlanarBW, FiltOptions);
fprintf('Applying filter in t,v');
[LFFilt, FiltOptionsOut] = LFFilt2DFFT( LF, Htv, [1,3], FiltOptions );
FiltOptionsOut
LFFigure(CurFigure);
CurFigure = CurFigure + 1;
LFDisp(LFFilt);
axis image off
truesize
title(sprintf('Freq. line filt. t,v; slope %.3g, BW %.3g', PlanarSlope, PlanarBW));
drawnow
fprintf('Building 2D frequency line... ');
Hsu = LFBuild2DFreqLine( LFSize([2,4]), PlanarSlope, PlanarBW, FiltOptions);
fprintf('Applying filter in s,u');
[LFFilt, FiltOptionsOut] = LFFilt2DFFT( LFFilt, Hsu, [2,4], FiltOptions );
LFFigure(CurFigure);
CurFigure = CurFigure + 1;
LFDisp(LFFilt);
axis image off
truesize
title(sprintf('Freq. line filt. t,v then s,u; slope %.3g, BW %.3g', PlanarSlope, PlanarBW));
drawnow
%---Demonstrate 4D Planar filter---
fprintf('Building 4D frequency plane... ');
[H, FiltOptionsOut] = LFBuild4DFreqPlane( LFSize, PlanarSlope, PlanarBW );
fprintf('Applying filter');
[LFFilt, FiltOptionsOut] = LFFilt4DFFT( LF, H, FiltOptionsOut );
FiltOptionsOut
LFFigure(CurFigure);
CurFigure = CurFigure + 1;
LFDisp(LFFilt);
axis image off
truesize
title(sprintf('Frequency planar filter, slope %.3g, HyperfanBW %.3g', PlanarSlope, PlanarBW));
drawnow
%%
%---Demonstrate 4D Hyperfan filter---
fprintf('Building 4D frequency hyperfan... ');
[H, FiltOptionsOut] = LFBuild4DFreqHyperfan( LFSize, HyperfanSlope1, HyperfanSlope2, HyperfanBW );
fprintf('Applying filter');
[LFFilt, FiltOptionsOut] = LFFilt4DFFT( LF, H, FiltOptionsOut );
FiltOptionsOut
LFFigure(CurFigure);
CurFigure = CurFigure + 1;
LFDisp(LFFilt);
axis image off
truesize
title(sprintf('Frequency hyperfan filter, slopes %.3g, %.3g, HyperfanBW %.3g', HyperfanSlope1, HyperfanSlope2, HyperfanBW));
drawnow