Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LF
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
LightFieldCodingLibrary
LF
Commits
25149a7a
Commit
25149a7a
authored
5 years ago
by
DIB Elian
Browse files
Options
Downloads
Patches
Plain Diff
Simplified code
parent
44c13ef5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
toSubAps.m
+47
-54
47 additions, 54 deletions
toSubAps.m
with
47 additions
and
54 deletions
toSubAps.m
+
47
−
54
View file @
25149a7a
...
@@ -6,14 +6,17 @@ sz = size(data);
...
@@ -6,14 +6,17 @@ sz = size(data);
sz
=
sz
(
4
:
end
);
sz
=
sz
(
4
:
end
);
sz
(
end
+
1
:
2
)
=
1
;
sz
(
end
+
1
:
2
)
=
1
;
mask
=
true
(
sz
);
mask
=
true
(
sz
);
maxValue
=
[];
if
isinteger
(
data
);
maxValue
=
intmax
(
class
(
data
));
end
p
=
inputParser
();
p
=
inputParser
();
p
.
addParameter
(
'name'
,
''
,
@
ischar
);
p
.
addParameter
(
'name'
,
''
,
@
ischar
);
p
.
addParameter
(
'shift'
,
0
,
@
isnumeric
);
p
.
addParameter
(
'shift'
,
0
,
@
isnumeric
);
p
.
addParameter
(
'mask'
,
mask
,
@
(
x
)
islogical
(
x
)
&&
isequal
(
size
(
x
),
size
(
mask
)));
p
.
addParameter
(
'mask'
,
mask
,
@
(
x
)
islogical
(
x
)
&&
isequal
(
size
(
x
),
size
(
mask
)));
p
.
addParameter
(
'ext'
,
'png'
,
@
ischar
);
p
.
addParameter
(
'ext'
,
'png'
,
@
ischar
);
p
.
addParameter
(
'map'
,
[]
,
@
(
x
)
isempty
(
x
)
||
isnumeric
(
x
));
p
.
addParameter
(
'map'
,
[]
,
@
(
x
)
isempty
(
x
)
||
isnumeric
(
x
));
p
.
addParameter
(
'alpha'
,
[]
,
@
(
x
)
isempty
(
x
)
||
isnumeric
(
x
));
p
.
addParameter
(
'alpha'
,
[]
,
@
(
x
)
isempty
(
x
)
||
isnumeric
(
x
));
p
.
addParameter
(
'maxValue'
,
[]
,
@
(
x
)
isempty
(
x
)
||
isnumeric
(
x
));
p
.
addParameter
(
'maxValue'
,
maxValue
,
@
(
x
)
isempty
(
x
)
||
isnumeric
(
x
));
p
.
parse
(
varargin
{:});
p
.
parse
(
varargin
{:});
name
=
p
.
Results
.
name
;
name
=
p
.
Results
.
name
;
...
@@ -24,34 +27,8 @@ map = p.Results.map;
...
@@ -24,34 +27,8 @@ map = p.Results.map;
alpha
=
p
.
Results
.
alpha
;
alpha
=
p
.
Results
.
alpha
;
maxValue
=
p
.
Results
.
maxValue
;
maxValue
=
p
.
Results
.
maxValue
;
if
~
startsWith
(
ext
,
'.'
)
if
~
startsWith
(
ext
,
'.'
);
ext
=
[
'.'
,
ext
];
end
ext
=
[
'.'
,
ext
];
if
~
exist
(
Dir
,
'dir'
);
mkdir
(
Dir
);
end
end
if
~
exist
(
Dir
,
'dir'
)
mkdir
(
Dir
)
end
switch
ext
case
'.png'
if
~
isempty
(
map
)
fun_write
=
@
(
frame
,
filename
)
imwrite
(
frame
,
map
,
fullfile
(
Dir
,[
filename
,
'.png'
]));
elseif
~
isempty
(
alpha
)
fun_write
=
@
(
frame
,
frame_alpha
,
filename
)
imwrite
(
frame
,
fullfile
(
Dir
,[
filename
,
'.png'
]),
'Alpha'
,
frame_alpha
);
else
fun_write
=
@
(
frame
,
filename
)
imwrite
(
frame
,
fullfile
(
Dir
,[
filename
,
'.png'
]));
end
case
'.pfm'
data
=
single
(
data
);
warning
(
'implicit conversion to single in pfmwrite'
);
fun_write
=
@
(
frame
,
filename
)
LF
.
pfmwrite
(
frame
,
fullfile
(
Dir
,[
filename
,
'.pfm'
]));
case
'.mat'
fun_write
=
@
(
frame
,
filename
)
save
(
fullfile
(
Dir
,[
filename
,
'.mat'
]),
'disparity'
,
frame
);
case
{
'.ppm'
,
'.pgm'
}
fun_write
=
@
(
frame
,
max_value
,
filename
)
imwrite
(
frame
,
fullfile
(
Dir
,[
filename
,
ext
]),
'MaxValue'
,
max_value
);
otherwise
fun_write
=
@
(
frame
,
filename
)
imwrite
(
frame
,
fullfile
(
Dir
,[
filename
,
ext
]));
end
frames
=
LF
.
toSlices
(
data
);
frames
=
LF
.
toSlices
(
data
);
...
@@ -66,39 +43,55 @@ else
...
@@ -66,39 +43,55 @@ else
filenames
=
cellfun
(
@
(
index
)
strjoin
([
name
,
index
],
'_'
),
indices
,
'UniformOutput'
,
false
);
filenames
=
cellfun
(
@
(
index
)
strjoin
([
name
,
index
],
'_'
),
indices
,
'UniformOutput'
,
false
);
end
end
filenames
=
cellfun
(
@
(
filename
)
fullfile
(
Dir
,[
filename
,
ext
]),
filenames
,
'UniformOutput'
,
false
);
frames
=
frames
(
mask
);
frames
=
frames
(
mask
);
filenames
=
filenames
(
mask
);
filenames
=
filenames
(
mask
);
if
~
isempty
(
alpha
)
frames_alpha
=
LF
.
toSlices
(
alpha
);
frames_alpha
=
frames_alpha
(
mask
);
end
switch
ext
switch
ext
case
'.png'
case
'.png'
if
~
isempty
(
alpha
)
if
~
isempty
(
map
)
frames_alpha
=
LF
.
toSlices
(
alpha
);
if
~
isempty
(
alpha
)
frames_alpha
=
frames_alpha
(
mask
);
fun_write
=
@
(
frame
,
frame_alpha
,
filename
)
...
cellfun
(
fun_write
,
frames
,
frames_alpha
,
filenames
);
imwrite
(
frame
,
filename
,
'Alpha'
,
frame_alpha
);
else
cellfun
(
fun_write
,
frames
,
frames_alpha
,
filenames
);
else
fun_write
=
@
(
frame
,
filename
)
imwrite
(
frame
,
map
,
filename
);
cellfun
(
fun_write
,
frames
,
filenames
);
end
elseif
~
isempty
(
alpha
)
fun_write
=
@
(
frame
,
frame_alpha
,
filename
)
...
imwrite
(
frame
,
filename
,
'Alpha'
,
frame_alpha
);
cellfun
(
fun_write
,
frames
,
frames_alpha
,
filenames
);
else
fun_write
=
@
(
frame
,
filename
)
imwrite
(
frame
,
filename
);
cellfun
(
fun_write
,
frames
,
filenames
);
cellfun
(
fun_write
,
frames
,
filenames
);
end
end
case
'.mat'
case
'.mat'
for
it
=
1
:
numel
(
frames
)
for
it
=
1
:
numel
(
frames
)
disparity
=
frames
{
it
};
disparity
=
frames
{
it
};
filename
=
fullfile
(
Dir
,[
filenames
{
it
}
,
'.mat'
])
;
filename
=
filenames
{
it
};
save
(
filename
,
'disparity'
);
save
(
filename
,
'disparity'
);
end
end
case
{
'.pgm'
,
'.ppm'
}
case
{
'.pgm'
,
'.ppm'
}
if
isempty
(
maxValue
)
fun_write
=
@
(
frame
,
filename
)
imwrite
(
frame
,
filename
,
'MaxValue'
,
maxValue
);
if
isinteger
(
frames
{
1
})
maxValue
=
intmax
(
class
(
frames
{
1
}));
else
maxValue
=
255
;
end
end
maxValue
=
num2cell
(
maxValue
*
ones
(
size
(
frames
)));
cellfun
(
fun_write
,
frames
,
filenames
);
cellfun
(
fun_write
,
frames
,
maxValue
,
filenames
);
case
'.pfm'
warning
(
'implicit conversion to single in pfmwrite'
);
fun_write
=
@
(
frame
,
filename
)
LF
.
pfmwrite
(
single
(
frame
),
filename
);
cellfun
(
fun_write
,
frames
,
filenames
);
otherwise
otherwise
fun_write
=
@
(
frame
,
filename
)
imwrite
(
frame
,
filename
);
cellfun
(
fun_write
,
frames
,
filenames
);
cellfun
(
fun_write
,
frames
,
filenames
);
end
end
end
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment