[Insight-users] Spacing problem
    Wolfram Timm 
    comail at mac.com
       
    Wed Oct 24 18:06:18 EDT 2012
    
    
  
Hi,
I don't get the background of this problem:
Inside a DLL I am trying to create a 3D ITK image of type unsigned short. This works (filewriter successful), when spacing is 1.0 for each dimension. Inside the DLL I get an Access Violation even preventing throwing the exception when choosing a different spacing like 0.2, 0.2, 2.0 (yes, awful anisotropy). This is independent of the use of ITKImportFilter or creating just an ITK image.
Here's the relevant code (afaik):
typedef unsigned short PixelType;
typedef itk::Image< PixelType, 3 > ImageType;
  ImageType::Pointer img = ImageType::New();
  ImageType::SizeType size;
  size[0] = 512;
  size[1] = 512;
  size[2] = 86;
  ImageType::IndexType start;
  start.Fill(0);
  ImageType::RegionType region;
  region.SetIndex(start);
  region.SetSize(size);
  img->SetRegions(region);
  double origin[3];
  origin[0] = 0.0;
  origin[1] = 0.0;
  origin[2] = 0.0;
  img->SetOrigin(origin);
  ImportImageFilterType::SpacingType spacing;
  spacing[0] = 0.2;
  spacing[1] = 0.2;
  spacing[2] = 2.0;
  img->SetSpacing(spacing);
  try
      {
      log("img pre Allocate()");
      img->Allocate();
      log("img pos Allocate()");
  }
  catch( itk::ExceptionObject & exp )
  {
      log("Exception caught !");
      log((string)exp.GetDescription());
  }
  WriterType::Pointer writer = WriterType::New();
  writer->SetFileName("d:\\temp\\i.tif");
  writer->SetInput(img);
  try
  {
      writer->Update();
  }
  catch( itk::ExceptionObject & exp )
  {
      log("Exception caught !");
      log((string)exp.GetDescription());
  }
Any help really is appreciated, since I don't get the problem here.
Thanks.
Wolfram
    
    
More information about the Insight-users
mailing list