% - Simple function to fill a stack with images % % [ImStack] = fillstack (path, filename, format, images, dim, ) % ImStack : 3D array containing the images % path : String containing the path % filename : String containing the filename without the numbers % format : 'img' - tvx .img format % 'tif' - tif format with extension .tif % 'tiff' - tif format with extension .tiff % 'ff' - tvx flatfield tif format (= float tif) % with extension .tif % 'edf' - edf: ESRF data format as .edf % images : Integer vector of the format images = [start end] % dim : Matrix dimension as vector, e.g. dim = [xdim, ydim] % colorDepth: Color depth of the .img file in number of bits % (default 32). colorDepth can be % - 8 % - 16 (for PILATUS 1 images) % - 32 (for PILATUS 2 images) or % - 64 %========================================================================== % % FUNCTION: fillstack.m % =========== % % $Date: 2006/12/11 12:39:13 $ % $Author: pauli_s $ % $Revision: 1.6 $ % $Source: /import/cvs/X/PILATUS/App/lib/X_PILATUS_Matlab/fillstack.m,v $ % $Tag: $ % % % - Simple function to fill a stack with images % % Author(s): R. Herger (RH) % Co-author(s): C.M. Schlepuetz (CS) % S.A. Pauli (SAP) % Address: Swiss Light Source (SLS) % Paul Scherrer Institute % CH - 5232 Villigen PSI % Created: 2004/09/16 % % Change Log: % ----------- % % 2005/11/11 (RH): % - first version % % 2006/02/17 (SAP): % - added format to input arguments % % 2006/10/20 (SAP): % - added edf to format-input-arguments and corrected the orange-errors. %========================================================================== % Main function - fillstack % ========= function [ImStack] = fillstack(path, filename, format, images, dim, colorDepth) % start the cpu clock % clockstart = cputime; %---------------------- % check input arguments % are there 5 ... 6 input arguments? error(nargchk(5, 6, nargin)); % is path of type string? if(~ischar(path)) error(strcat('Invalid input for ''path'' in function fillstack.m.\n', ... 'Use ''help fillstack'' for further information.'), ... ''); end % is filename of type string? if(~ischar(filename)) error(strcat('Invalid input for ''filename'' in function fillstack.m.\n', ... 'Use ''help fillstack'' for further information.'), ... ''); end % is format img, tif, tiff or ff? if ((strcmpi(format,'img') | strcmpi(format,'tif') | ... strcmpi(format,'tiff') | strcmpi(format,'ff') | ... strcmpi(format,'edf')) ~= 1) error(strcat('Invalid input for ''format'' in function imageread.\n', ... 'Use ''help imageread'' for further information.'), ... ''); end % is dim a images an integer array of size [1 2]? if (isnumeric(images)) if (~isequal(size(images), [1 2])) error(strcat('Invalid input for ''images'' in function fillstack.m.\n', ... 'Use ''help fillstack'' for further information.'), ... ''); end; else error(strcat('Invalid input for ''images'' in function fillstack.m.\n', ... 'Use ''help fillstack'' for further information.'), ... ''); end; % is dim a vector of size [1 2]? if (~isequal(size(dim), [1 2])) error(strcat('Invalid input for ''dim'' in function fillstack.\n', ... 'Use ''help fillstack'' for further information.'), ... ''); end % is colorDepth equal to 8, 16, 32, or 64? if (nargin < 6) colorDepth = 32; end; if (colorDepth ~= 8 && colorDepth ~= 16 &&... colorDepth ~= 32 && colorDepth ~= 64) error(strcat('Invalid input for ''colorDepth'' in function fillstack.m.', ... '\nUse ''help imageread'' for further information.'), ... ''); end; % is colorDepth an integer value? if (~isnumeric(colorDepth)) error(strcat('Invalid input for ''colorDepth'' in function ', ... ' fillstack.m.\n Use ''help fillstack'' for further ', ... ' information.'), ... ''); end; %---------------------- % check output argument % is 1 output argument specified? error(nargoutchk(1, 1, nargout)); %--------------- % fill the stack % initialize some variables q = 1; zdim = length(images(1,1):images(1,2)); ImStack = zeros(dim(2),dim(1),zdim); % create the stack for i=images(1,1):images(1,2) no = sprintf ('%05d', i); actualImage = strcat (path, filename, no); ImStack (:, :, q) = imageread (actualImage, format, dim, colorDepth); q = q + 1; end; % clear some variables clear q no actualimage format clockstart clockend time; %========================================================================== % %---------------------------------------------------% % emacs setup: force text mode to get no help with % % indentation and force use of spaces % % when tabbing. % % Local Variables: % % mode:text % % indent-tabs-mode:nil % % End: % %---------------------------------------------------% % % $Log: fillstack.m,v $ % Revision 1.6 2006/12/11 12:39:13 pauli_s % added tag % % Revision 1.5 2006/11/21 15:45:58 pauli_s % added edf, corrected orange errors % % Revision 1.4 2006/08/17 14:30:57 pauli_s % ubcalc.m % % Revision 1.3 2006/02/17 13:11:02 pauli_s % added format to imput arguments % % Revision 1.2 2005/11/14 12:36:00 herger % changed wrong argument in the help text % % Revision 1.1 2005/11/11 11:45:48 herger % matlab function to create a stack of images % % %================================= End of .m ================