[Insight-users] problem allocating an image

john smith mkitkinsightuser at gmail.com
Wed Jun 15 18:20:55 EDT 2011


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 ));
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110616/3ecb9ca7/attachment.htm>


More information about the Insight-users mailing list