Path: news.mathworks.com!not-for-mail
From: "Arron S" <aps@uwm.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Array of Images Running out of memory
Date: Tue, 6 Jan 2009 05:14:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 41
Message-ID: <gjupaq$jeu$1@fred.mathworks.com>
Reply-To: "Arron S" <aps@uwm.edu>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1231218842 19934 172.30.248.37 (6 Jan 2009 05:14:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 6 Jan 2009 05:14:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1655593
Xref: news.mathworks.com comp.soft-sys.matlab:509961


I am very very new to matlab and have written my first M-file. It is functional for a test set of 38 images but my data sets are in the range of 400. (144x512)

When I try to run it with a full data set I get an obvious memory error.  I realize that I am running 32bit XP and thus don't have a large enough contiguous memory for my data. But I know that others are able to get around this and I would like to know how. This should be easy to answer since I have read a lot of posts where people have arrays of a good deal of images but they did not explain how they were doing it. I looked at a few hundred file exchange files and searched this forum before I decided to post this message.  I did not find an answer that I understood.  Any help or links to topics pointing me in the right direction would be very helpful. 

My aim is to load about 400 images and run FRET analysis. 
Below is my code (probably not optimal, and itis currently molded for my data with no input/error checks yet) I used ReadDicom4.m by Nipun Patel to teach myself some of the basics and hence some of the variables are of the same name.

Thank you in advance,
Arron



function a = imagestack(sequenceStartNo,sequenceEndNo, fileExtension)
tic


fileCount=0;
totalFiles = sequenceEndNo - sequenceStartNo;
a= zeros(144,512,totalFiles);  % preallocation

j=1;

for i=sequenceStartNo:sequenceEndNo 
    
    sequenceNo=num2str(i);
    filename = strcat(sequenceNo,fileExtension);
    varname = imread (filename);
    varname = mat2gray(varname);
    
    fileCount = fileCount + 1;
    
    a(:,:,j)= varname;
    
    j = j+1;
end

toc
display (fileCount);