-
Notifications
You must be signed in to change notification settings - Fork 2
/
LFDisp.m
55 lines (47 loc) · 1.47 KB
/
LFDisp.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
% LFDisp - Convenience function to display a 2D slice of a light field
%
% Usage:
% LFSlice = LFDispMousePan( LF )
% LFDispMousePan( LF )
%
%
% The centermost image is taken in s and t. Also works with 3D arrays of images. If an output argument is included, no
% display is generated, but the extracted slice is returned instead.
%
% Inputs:
%
% LF : a colour or single-channel light field, and can a floating point or integer format. For
% display, it is scaled as in imagesc. If LF contains more than three colour
% channels, as is the case when a weight channel is present, only the first three are used.
%
%
% Outputs:
%
% LFSlice : if an output argument is used, no display is generated, but the extracted slice is returned.
%
%
% See also: LFDispVidCirc, LFDispMousePan
% Part of LF Toolbox v0.4 released 12-Feb-2015
% Copyright (c) 2013-2015 Donald G. Dansereau
function ImgOut = LFDisp( LF )
LF = squeeze(LF);
LFSize = size(LF);
HasWeight = (ndims(LF)>2 && LFSize(end)==2 || LFSize(end)==4);
HasColor = (ndims(LF)>2 && (LFSize(end)==3 || LFSize(end)==4) );
HasMonoAndWeight = (ndims(LF)>2 && LFSize(end)==2);
if( HasColor || HasMonoAndWeight )
GoalDims = 3;
else
GoalDims = 2;
end
while( ndims(LF) > GoalDims )
LF = squeeze(LF(round(end/2),:,:,:,:,:,:));
end
if( HasWeight )
LF = squeeze(LF(:,:,1:end-1));
end
if( nargout > 0 )
ImgOut = LF;
else
imagesc(LF);
end