[Insight-users] Persisting a dynamically created image onto the file system

Shlomo Kashani. shlomo_kashani at yahoo.com
Mon Jun 26 13:07:25 EDT 2006


Hi,
  For testing teh impulse response of some function I need to create an n*n image with zeros in in except for the central pixel which is supposed to be 1. Assuming I can correctly acomplish that (see teh code below), how do I write the dynamically allocated image using  itk::ImageFileWriter ?
   
  Thank you very much, 
  Shlomo Kashani. 
   
  ...
  typedef itk::Image<unsigned short,2> ImageType2D;
  typedef itk::ImageFileReader<ImageType2D> ReaderType;
  typedef itk::ImageFileWriter< ImageType2D > WriterType;
  // create a new image 
  ImageType2D::Pointer smallImage = ImageType2D::New();
  
  // define the size of the image 
  ImageType2D::SizeType size;
  size[0] = 50; // size along X
  size[1] = 50; // size along Y
  // define the starting position of the image 
  ImageType2D::IndexType start;
  start[0] = 0; // first index on X
  start[1] = 0; // first index on Y
  
  // define a region using the starting position and size 
  // declared earlier 
  ImageType2D::RegionType region;
  region.SetSize( size );
  region.SetIndex( start );
  // set the region to be processed
  smallImage->SetRegions( region );
  // allocate memory for the region
  smallImage->Allocate();
  // write the pixles
  ...
  ....
  // create new image reader, NOT sure if I need that 
  ReaderType::Pointer reader = ReaderType::New();
  // create new image writer
  WriterType::Pointer writer = WriterType::New();
  
   
  //How do I use the writer to persist smallimage ?
   
   

 		
---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060626/f04aff0d/attachment.htm


More information about the Insight-users mailing list