Reputation: 11
I have some problem with Stanford Lytro Light Field Archive dataset. In this dataset, it only offer undemosaic png file (which is decoded Lytro ESLF) and metadata file separately.
I'm wondering if there are any ways that I can apply the metadata on the png and demosaic it, or merging them together to recover the png file.
Any suggestions would be greatly appreciated 🙂
The dataset's website: http://lightfields.stanford.edu/LF2016.html
I have already tried to use "Matlab Light Field ToolBox" to demosaic, but the tutorial only shows how to do with .lfp file.
The toolBox's website: https://ww2.mathworks.cn/matlabcentral/fileexchange/49683-light-field-toolbox-v0-4
Upvotes: 1
Views: 287
Reputation: 1122
I use the following MATLAB code from here, you can modify according to the number of views you want. Current Light Field Toolbox provides function to read ESLf files. Download the toolbox from here. Other than this, from the Light Field forum:
The png files are the demosaiced raw images, also known as lenslet images, corresponding to a set of micro-images; you can render this lenslet image in form of multi-view sub-aperture images by putting together the pixels in the same position within each micro-image to create a rendered image for a specific viewpoint; So, basically what you get in the end is the same as the toolbox's output.
% generates 14x14 views and saves only 8x8 of those
% uses light-field-MATLAB toolbox
folders = dir('/path/to/ESLF/images');
dirFlags =[folders.isdir];
subFolders = folders(dirFlags);
imgNo=0;
for k = 1 : length(subFolders)
if subFolders(k).name ~= '.' | subFolders(k).name ~= '..'
currfolder=fullfile('/path/to/ESLF/images',subFolders(k).name,'raw');
fprintf("Working on : ")
fprintf(currfolder);
fprintf('\n')
files = dir(fullfile(currfolder,'*.png'));
for loop = 1:length(files)
imgNo = imgNo + 1;
file=files(loop).name;
f = fullfile(currfolder,file);
LF = LFReadESLF(f);
viewsfoldername = '/path/to/save/views';
newfolder=sprintf('%s/%d',viewsfoldername,imgNo);
mkdir(newfolder)
for i = 4:11
for j = 4:11
view = squeeze(LF(j,i,:,:,1:3));
filename = fullfile(newfolder, sprintf('view_%d_%d_%d.png',imgNo,j,i));
imwrite(view, filename);
end
end
end
end
end
It's an old question, but if you had experience with working with the files let me know if you figured out some other way.
Upvotes: 0
Reputation: 2179
I don't know if this is correct, but the resulting images look reasonable.
Pick every n, m
-th pixel, starting with offset s, t
, given an ESLF image eslf_img
in numpy format (from cv.imread
):
for s in range(n):
for t in range(m):
view = eslf_img[s::n, t::m, ...]
# do something with view
For all ESLF images I've encountered, n = m = 14
.
This is purely empirical. I appreciate comments and suggestions.
Upvotes: 1