rtsLoadImageStack.m 746 Bytes
function R = rtsLoadImageStack(directoryName)

fileList = dir(directoryName);
fileList = fileList(3:length(fileList));

nFiles = length(fileList);

%enable the progress bar
gui_active(1);
h = progressbar([], 0, ['Loading ' num2str(nFiles) ' Images...'], 'Load Stack');


%load each file into a volume
for i=1:nFiles
    fileName = [directoryName '\' fileList(i).name];
    image = imread(fileName);
    
    %allocate space
    if i == 1
        R = zeros(size(image, 1), size(image, 2), nFiles, 'uint8');
    end
    R(:, :, i) = image(:, :, 1);
    
    h = progressbar(h, 1/(nFiles));
    if ~gui_active
        progressbar(h, -1);
        break;                            
    end
end

progressbar(h, -1);