/usr/share/psychtoolbox-3/PsychHardware/BrightSideDisplay/HDRRead.m is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | function img = HDRRead(imgfilename, continueOnError, flipit)
% img = HDRRead(imgfilename[, continueOnError=0][, flipit=0])
% Read a high dynamic range image file and return it as Matlab double
% matrix, suitable for use with Screen('MakeTexture') and friends.
%
% 'imgfilename' - Filename of the HDR image file to load.
% Returns 'img' - A double precision matrix of size h x w x c where h is
% the height of the input image, w is the width and c is the number of
% color channels: 1 for luminance images, 2 for luminance images with alpha
% channel, 3 for true-color RGB images, 4 for RGB images with alpha
% channel.
%
% 'continueOnError' Optional flag. If set to 1, HDRRead won't abort on
% error, but simply return an empty img matrix. Useful for probing if a
% specific file type is supported.
%
% 'flipit' Optional flag: If set to 1, the loaded image is flipped upside
% down.
%
% HDRRead is a dispatcher for a collection of reading routines for
% different HDR image file formats. Currently supported are:
%
% * Run length encoded RGBE format, read via read_rle_rgbe.m, extension is
% ".hdr". Returns a RGB image.
%
% The reader routines are contributed code or open source / free software /
% public domain code downloaded from various locations under different, but
% GPL compatible licenses. See the help for the respective loaders for
% copyright and author information.
% History:
% 12/14/06 Written (MK).
if nargin < 1 || isempty(imgfilename)
error('Missing HDR image filename.');
end
if nargin < 2 || isempty(continueOnError)
continueOnError = 0;
end
if nargin < 3 || isempty(flipit)
flipit = 0;
end
% Format dispatcher:
dispatched = 0;
if ~isempty(findstr(imgfilename, '.hdr'))
% Load a RLE encoded RGBE high dynamic range file:
dispatched = 1;
try
inimg = read_rle_rgbe(imgfilename);
if flipit
img(:,:,1) = flipud(inimg(:,:,1));
img(:,:,2) = flipud(inimg(:,:,2));
img(:,:,3) = flipud(inimg(:,:,3));
else
img(:,:,1) = inimg(:,:,1);
img(:,:,2) = inimg(:,:,2);
img(:,:,3) = inimg(:,:,3);
end
catch
if continueOnError
img = [];
warning(['HDR file ' imgfilename ' failed to load.']);
msg = psychlasterror;
disp(msg.message);
return;
else
psychrethrow(psychlasterror);
end
end
end
if dispatched == 0
if ~continueOnError
error(['HDR file ' imgfilename ' is of unknown type. No loader available.']);
else
img = [];
warning(['HDR file ' imgfilename ' is of unknown type. No loader available.']);
return;
end
end
% Done.
return;
|