Re: Memory when reding in data
- To: mathgroup at smc.vnet.net
- Subject: [mg120987] Re: Memory when reding in data
- From: "Alexey Popkov" <lehin.p at gmail.com>
- Date: Sat, 20 Aug 2011 06:17:58 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <j2lehm$ngv$1@smc.vnet.net>
Try to evaluate $HistoryLenght=0; and Clear variables when their values are no longer needed. "Peter Rodenbach" <peter.rodenbach at googlemail.com> wrote: news:j2lehm$ngv$1 at smc.vnet.net... > Hi everyone. > > I am analysing image data and I have the problem that after about 50 > images or so Mathematica quits the calculation with the hint out of > memory. The interesting part of the code i wrote is : > > (*Import the first image into Maxvals, which will be compared to all \ > other images and overwritten if any point is found to be larger*) > > SetDirectory[ > "E:\\...]; > > Initialise = OpenRead["s2_260_0000.edf", BinaryFormat -> True]; > MaxValues = > BinaryRead["s2_260_0000.edf", > Table["UnsignedInteger16", {512}, {512}]]; > counter = Dimensions[MaxValues]; > > (*Load all experimental images and perform maximum projection*) > > MaxProjection[filename_] := {OpenRead[filename, BinaryFormat -> True], > Imagevalues = > BinaryRead[filename, Table["UnsignedInteger16", {512}, {512}]], > For[i = 1, i <= counter[[1]], i++, > For [j = 1, j <= counter[[2]], j++, > If[MaxValues[[i, j]] >= Imagevalues[[i, j]], > MaxValues[[i, j]] = MaxValues[[i, j]], > MaxValues[[i, j]] = Imagevalues[[i, j]]] > ] > ], Close[Imagevalues]} > > > MaxProjection[#] & /@ FileNames@"*edf" > > So I guess Mathm saves all the data of all the images after each > other. But once the comparision is done with the one MaxProjection > Image I want to have, all the data can be dumped from the memory and > then the next image can be compared with this MaxProjection image. > > Does anyone have an idea? Thx. >