Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Array of Images Running out of memory
Date: Tue, 6 Jan 2009 10:00:38 -0500
Organization: The MathWorks, Inc.
Lines: 42
Message-ID: <gjvrmm$8rq$1@fred.mathworks.com>
References: <gjupaq$jeu$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1231254038 9082 144.212.105.187 (6 Jan 2009 15:00:38 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 6 Jan 2009 15:00:38 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:510034



"Arron S" <aps@uwm.edu> wrote in message 
news:gjupaq$jeu$1@fred.mathworks.com...
>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.

The first question I'd ask is:  do you need to have all 38 (or 400) images 
loaded into memory at the same time?  Can you instead read in one image, 
perform the necessary calculations, and then repeat for the remainder of 
your images?

Pete's suggestion about using a different data type may help as well, 
particularly if the images can be stored and processed as one of the integer 
data types (like int8 or uint8, which would use one eighth the memory of 
storing it as a double.)  If all the images can be stored as int8's, for 
instance, then preallocate with:

a = zeros(144, 512, totalFiles, 'int8');

-- 
Steve Lord
slord@mathworks.com