[Insight-users] A memory issue

Ali Mouizina ali.mouizina at gmail.com
Mon Jan 23 04:41:33 EST 2012


Why don't you put your coordinates in the same order as in the definition of
the size variable? --> I would say it's a lack of rigor but it doesn't
change anything to the problem. 

Also, this is not a bug, but wouldn't it be nicer to write 152 instead 
of 'ÿ'? --> 'ÿ' <=> 255 :). My code is much bigger and I can't show it here
that's why I made a small code highlighting my problem ;). 

Moreover, when the dimension of my vector is smaller (512*512*25*125 for
instance), my program works fine, but when the third dimension is bigger
(like 150 it crashes even if the memory has been allocated correctly.)
However if I put ' weight2->GetPixel(pixelIndex_weight);' instead of '
weight2->SetPixel(pixelIndex_weight,'ÿ');' it works fine even for large
dimensions. 

Regards,

Ali

-----Message d'origine-----
De : insight-users-bounces at itk.org [mailto:insight-users-bounces at itk.org] De
la part de Kevin Keraudren
Envoyé : lundi 23 janvier 2012 09:32
À : insight-users at itk.org
Objet : Re: [Insight-users] A memory issue

Le 22/01/2012 22:35, Ali Mouizina a écrit :
> 	Weightimage::SizeType size;
> 	size[0]=nb_col; //->  nb_col is set in the constructor
> 	size[1]=nb_ln;
> 	size[2]=nb_slice;
> 	size[3]=124;
>
> 	for (int l=0;l<124;l++){ // -->  After a few iterations it crashes
> 		for (int i=0;i<nb_ln;i++)
> 			for (int j=0;j<nb_col;j++)
> 				for (int k=0;k<nb_slice;k++){
> 					pixelIndex_weight[0]=j;
> 					pixelIndex_weight[1]=i;
> 					pixelIndex_weight[2]=k;
> 					pixelIndex_weight[3]=l;

Why don't you put your coordinates in the same order as in the definition of
the size variable?


     for (int i=0; i<nb_col; i++){
         for (int j=0;j<nb_ln; j++)
             for (int k=0; k<nb_slice; k++)
                 for (int l=0; l<124; l++){

                     pixelIndex_weight[0]=i;
                     pixelIndex_weight[1]=j;
                     pixelIndex_weight[2]=k;
                     pixelIndex_weight[3]=l;

Also, this is not a bug, but wouldn't it be nicer to write 152 instead 
of 'ÿ'?

Kind regards,

Kevin


_____________________________________
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



More information about the Insight-users mailing list