[Insight-users] problem allocating an image

robert tamburo robert.tamburo at gmail.com
Wed Jun 15 18:35:32 EDT 2011


Looks like a case of the copy/paste bug:
"for(unsigned int k = 0; j < size_z; j++)"

P.S. Use an image iterator :)

On Wed, Jun 15, 2011 at 6:20 PM, john smith <mkitkinsightuser at gmail.com>wrote:

> Hello to all,
>
> I am trying to do a simple task.Well, I am trying to create a 3D image.Fill
> all the vosels with value 255 and then get the max value (just to see if my
> program works fine).But every time it is running I get an exception which
> has to do with the area allocated in the memory.What am I doing wrong. ihope
> that someone could help me
>
> Thanks
>
>   InputImageType::Pointer image_norm;
>
>   InputImageType::IndexType start;
>   start.Fill(0);
>
>   InputImageType::SizeType size;
>   size[0]=size_x;
>   size[1]=size_y;
>   size[2]=size_z;
>
>
>   InputImageType::RegionType region(start, size);
>   image_norm->SetRegions(region);
>   image_norm->Allocate();
>   image_norm->FillBuffer(255);
>
>   int max=0;
>      for(unsigned int i = 0; i < size_x; i++)
>       {
>       for(unsigned int j = 0; j < size_y; j++)
>                 {
>         for(unsigned int k = 0; j < size_z; j++)
>                         {
>                                 InputImageType::IndexType pixelIndex;
>                                 pixelIndex[0] = i;
>                                 pixelIndex[1] = j;
>                                 pixelIndex[2] = k;
>
>                             int value= image_norm->GetPixel(pixelIndex);
>                             if (value>max){max=value;}
>                         }
>
>                 }
>       }
> ui->label_61->setText(QString("max:%1").arg( max ));
>
> _____________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110615/5429e751/attachment.htm>


More information about the Insight-users mailing list