[Insight-users] A memory issue
Ali Mouizina
ali.mouizina at gmail.com
Fri Jan 20 09:36:58 EST 2012
To Dzenan :
Thank you, I increased the virtual memory but I still can't allocate
memory for my vectors.
To alex :
Here is a part of my code :
Weights.h
typedef unsigned char PixelType;
const unsigned int Dimension3=3;
const unsigned int Dimension4=4;
typedef itk::Image<PixelType, Dimension3> ImageType;
typedef itk::Image<PixelType, Dimension4> Weightimage;
class Weights{
public:
Weights(ImageType::Pointer image, int patch_size, int region_size,
double var, int ln, int col, int nb_slices);
int get_hw2() {return hw2;}
Weightimage::Pointer get_weight() {return weight2;}
private:
int hw1; // Half-width (patch)
int hw2; // half-width (region)
double h2; //std of image noise
int nb_ln; // nb of rows
int nb_col; // nb of columns
int nb_slice; // nb of slices
ImageType::Pointer read;
Weightimage::Pointer weight2;
ImageType::Pointer imshift(int x, int y, int z);
};
Weights . cpp
Weights::Weights(ImageType::Pointer reader, int patch_size, int
region_size, double var, int ln, int col,int nb_slices)
: read(reader), hw1(patch_size), hw2(region_size), h2(var),
nb_ln(ln), nb_col(col),nb_slice(nb_slices)
{
weight2 = Weightimage::New();
Weightimage::IndexType start;
start[0]=0;
start[1]=0;
start[2]=0;
start[3]=0;
Weightimage::SizeType size;
size[0]=nb_col;
size[1]=nb_ln;
size[2]=nb_slice;
size[3]=125;
Weightimage::RegionType region;
region.SetSize(size);
region.SetIndex(start);
weight2->SetRegions(region);
weight2->Allocate(); //-> This is where it crashes
weight2->FillBuffer(0);
}
main.cpp
ImageType::IndexType pixelIndex;
typedef itk::ImageFileReader< ImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New(),reader2 =
ReaderType::New();
const char *inputFilename="3DGado_1_brain";
const char *inputFilename2="3DGado_2_1";
reader->SetFileName(inputFilename);
reader->Update();
reader2->SetFileName(inputFilename2);
reader2->Update();
ImageType::Pointer image=reader->GetOutput(),
image2=reader2->GetOutput();
Weights w1(image,1,2,10,512,512,22); //-> I can instantiate only
this one
Weights w2(image2,1,2,10,512,512,22); //-> For this one it crashes
at Weight.cpp :: weight2->Allocate();
Normally I should have enough memory for w1 and w2 (with unsigned char
used as the pixeltype).
Regards,
Ali
Le 20/01/2012 13:59, alex Dowson a écrit :
> Hi
>
>
> Can you show your code that we can understand little what you trying
> to do ?
>
>
>
> Alex
>
>
> -----Original Message----- From: Ali Mouizina
> Sent: Friday, January 20, 2012 6:21 PM
> To: insight-users at itk.org
> Subject: Re: [Insight-users] A memory issue
>
> To Dzenan :
>
> How can I do this ?
>
> To Kevin :
>
> All my values are within 0 and 1 but I think I can quantisize those
> values between 0 and 255. I tried your suggestion on a smaller image
> (and hence a smaller vector 512*512*22*125 <=> 671 MB with unsigned
> char) but it crashes when I instantiate 2 vectors (it works with 1). By
> the way I have a 8 GB of RAM and windows 7 64 bits. How can I fix this ?
>
> Thank you very much for your help !
>
> Regards,
>
> Ali
>
> Le 20/01/2012 13:09, Kevin Keraudren a écrit :
>> Also, changing PixelType and using a smaller type would save memory. Of
>> course, not all algorithms can live with unsigned char.
>>
>> unsigned char: 512*512*156*125/1024/1024/1024 ~ 4.8 GB
>> double: 512*512*156*125*8/1024/1024/1024 ~ 38.1 GB
>>
>>
>> On 20/01/12 11:26, Dženan Zukić wrote:
>>> Have you tried increasing virtual memory/swap file size? That should do
>>> it, I think. But it would be slower, of course.
>>>
>>> On Fri, Jan 20, 2012 at 11:31, Ali Mouizina<ali.mouizina at gmail.com
>>> <mailto:ali.mouizina at gmail.com>> wrote:
>>>
>>> Hi all,
>>>
>>> I'm currently trying to allocate a 4-D vector whose size is
>>> 512*512*156*125 to store the results of some computations i do
>>> on a
>>> 3D image. As expected, I don't have enough memory, is there any
>>> trick to get round this problem ?
>>>
>>> The results I get at each iteration of the computation process is
>>> stored into a slice of the 4D vector, so I thought I can process
>>> each slice separately. Any suggestions on how to do that or any
>>> other ideas ?
>>>
>>> Regards,
>>>
>>> Ali
>>>
>>> ------------------------------__-----------------------
>>>
>>> _______________________________________
>>> Powered by www.kitware.com<http://www.kitware.com>
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/__opensource/opensource.html
>>> <http://www.kitware.com/opensource/opensource.html>
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/__products/protraining.html
>>> <http://www.kitware.com/products/protraining.html>
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK___FAQ<http://www.itk.org/Wiki/ITK_FAQ>
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/__listinfo/insight-users
>>> <http://www.itk.org/mailman/listinfo/insight-users>
>>>
>>>
>>>
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.html
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-users
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>
--
Ali Mouizina
Diplômé en Traitement Numérique du Signal
Elève-Ingénieur en Traitement d'images
Mastère Spécialisé Telecom ParisTech : Signal, Images et Reconnaissance de formes
Paris - FRANCE
---------------------------------------------------------------------------------
Ali Mouizina
Graduated in Digital Signal Processing
Currently studying Image Processing
Advanced Masters at Telecom ParisTech : Signal, Images and Pattern Recognition
Paris - FRANCE
---------------------------------------------------------------------------------
More information about the Insight-users
mailing list