[Insight-users] Help with the itk::ImportImageFilter object please.

Ricardo Ferrari ferrari.toronto at gmail.com
Wed May 16 11:40:53 EDT 2007


Hi guys. Problem solved. My mistake.

Thanks.


/// Define the pixel type

typedef double PixelType;

/// Define the image type and its iterator

typedef itk::Image< PixelType, 3 > ImageType3D;

/// Define writer types

typedef itk::ImageFileWriter< ImageType3D > WriterType3D;

/// Import filter used to write the gabor filter to disk

typedef itk::ImportImageFilter< PixelType, 3 > ImportFilter3D;

typedef itk::VTKImageIO ImageIOType;

int m_dimU = 256;

int m_dimV = 256;

int m_dimW = 128;

const unsigned long int nPixels = m_dimU * m_dimV * m_dimW;

PixelType *buffer = new PixelType[ nPixels ];

// **************

ImportFilter3D::Pointer importFilter = ImportFilter3D::New();

ImportFilter3D::RegionType region;

ImportFilter3D::IndexType start;

start.Fill( 0 );

region.SetIndex( start );

ImportFilter3D::SizeType size;

size[0] = m_dimU;

size[1] = m_dimV;

size[2] = m_dimW;

region.SetSize( size );

importFilter->SetRegion( region );

double origin[3];

origin[0] = 0.0;

origin[1] = 0.0;

origin[2] = 0.0;

importFilter->SetOrigin( origin );

double spacing[3];

spacing[0] = 1.0;

spacing[1] = 1.0;

spacing[2] = 1.0;

importFilter->SetSpacing( spacing );

importFilter->SetImportPointer( buffer, nPixels, true );

// **************

// Set up the file writer

ImageIOType::Pointer vtkIO = ImageIOType::New();

vtkIO->SetByteOrderToLittleEndian();

vtkIO->SetNumberOfDimensions(3);

vtkIO->SetFileTypeToBinary();



// **************

WriterType3D::Pointer writerPtr = WriterType3D::New();

writerPtr->SetImageIO( vtkIO );

writerPtr->SetFileName( "C:\\Filter.vtk" );

writerPtr->SetInput( importFilter->GetOutput() );

writerPtr->Update();

// **************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070516/7ea103a7/attachment.html


More information about the Insight-users mailing list