Code covered by the BSD License  

Highlights from
Light Field Toolbox v0.1

image thumbnail
from Light Field Toolbox v0.1 by Donald Dansereau
A set of tools for working with light field (aka plenoptic) imagery in Matlab

...
% LFReadWhiteImageInfo - crawl through a folder of Lytro white images collecting information
%
% Usage: 
% 
%   [WhiteFileInfo, WhiteTextFileNames, WhiteImageFileNames] = 
%       LFReadWhiteImageInfo( CalibFilesPath )
% 
%   [WhiteFileInfo, WhiteTextFileNames, WhiteImageFileNames] = 
%       LFReadWhiteImageInfo( CalibFilesPath, WhiteTextFilenamePattern, WhiteImageFilenameExtension )
% 
% 
% This function is designed to work with a folder of Lytro white images, as extracted from the
% calibration data using an LFP tool.  There are several tools available, and each one generates
% slightly different output in terms of filenames.  This function was written and tested to work
% with python `LFP Reader' tool.
% 
% Input CalibFilesPath is a path to the folder containing the white images and their associated
% metadata files.
% 
% Optional Input WhiteTextFilenamePattern is a pattern, with wildcards, identifying the text
% (metadata) files associated with the white images.  The default value is '*T1CALIB__MOD_*.TXT' to
% match the output of the Python `LFP Reader' tool.
% 
% Optional Input WhiteImageFilenameExtension gives the extension of the white images.  The default
% value is `.RAW', to match the output of the Python `LFP Reader' tool.
% 
% See also:  LFUtilProcessLytroCalData

% Part of LF Toolbox v0.1, released 26-Apr-2013
% Copyright (c) 2013, Donald G. Dansereau

function [WhiteFileInfo, WhiteTextFileNames, WhiteImageFileNames] = ...
    LFGatherWhiteImageInfo( CalibFilesPath, WhiteTextFilenamePattern, WhiteImageFilenameExtension )

if( ~exist('WhiteTextFilenamePattern', 'var') )
    WhiteTextFilenamePattern = '*T1CALIB__MOD_*.TXT';
end
if( ~exist('WhiteImageFileExtension', 'var') )
    WhiteImageFilenameExtension = '.RAW';
end

WhiteTextFileNames = dir(fullfile(CalibFilesPath, WhiteTextFilenamePattern));
for( FIdx = 1:length(WhiteTextFileNames) )
    CurFileInfo = LFReadMetadata( fullfile(CalibFilesPath, WhiteTextFileNames(FIdx).name) );
    WhiteFileInfo(FIdx).ZoomStep = CurFileInfo.master.picture.frameArray{1}.frame.metadata.devices.lens.zoomStep;
    WhiteFileInfo(FIdx).FocusStep = CurFileInfo.master.picture.frameArray{1}.frame.metadata.devices.lens.focusStep;
    WhiteFileInfo(FIdx).ExposureDuration = CurFileInfo.master.picture.frameArray{1}.frame.metadata.devices.shutter.frameExposureDuration;
end

% The Lytro database has two exposures per zoom/focus setting -- this eliminates the darker one.
BrighterExposureIdx = find([WhiteFileInfo.ExposureDuration] >= mean([WhiteFileInfo.ExposureDuration]));
WhiteFileInfo = WhiteFileInfo( BrighterExposureIdx );
WhiteTextFileNames = WhiteTextFileNames( BrighterExposureIdx );

% The LF Reader tool prepends filenames, complicating .txt / .raw file association.  Here
% we find the raw file corresponding to each txt file
for( FIdx = 1:length(WhiteTextFileNames) )
    [~, CurFnameBase] = fileparts( WhiteTextFileNames(FIdx).name );
    PrependIdx = find(CurFnameBase == '_', 1);
    CurFnamePattern = strcat('*', CurFnameBase(PrependIdx:end), WhiteImageFilenameExtension);
    DirResult = dir(fullfile(CalibFilesPath, CurFnamePattern));
    WhiteImageFileNames(FIdx) = DirResult(1);  % warning: assumes only one result is meaningful
end

Contact us