[Insight-users] Problem generating a 3D volume from a set of slices
Dora Szasz
dora.szasz at yahoo.com
Tue May 17 16:19:27 EDT 2011
Hello all,
I am trying to make a 3D volume using a set of .png images. I want to obtain a 3D image (for example .mhd), but It doesn't generate any output.
My code is the following:
#include "itkImage.h"
#include "itkImageSeriesReader.h"
#include "itkImageFileWriter.h"
#include "itkNumericSeriesFileNames.h"
#include "itkPNGImageIO.h"
int main( int argc, char ** argv )
{
// Verify the number of parameters in the command line
if( argc < 4 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " firstSliceValue lastSliceValue outputImageFile " << std::endl;
return EXIT_FAILURE;
}
typedef unsigned char PixelType;
const unsigned int Dimension = 3;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageSeriesReader< ImageType > ReaderType;
typedef itk::ImageFileWriter< ImageType > WriterType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
const unsigned int first = atoi( argv[1] );
const unsigned int last = atoi( argv[2] );
const char * outputFilename = argv[3];
typedef itk::NumericSeriesFileNames NameGeneratorType;
NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
nameGenerator->SetSeriesFormat( "Dora00%02d.png" );
nameGenerator->SetStartIndex( first );
nameGenerator->SetEndIndex( last );
nameGenerator->SetIncrementIndex( 1 );
reader->SetImageIO( itk::PNGImageIO::New() );
reader->SetFileNames( nameGenerator->GetFileNames() );
writer->SetFileName( outputFilename );
writer->SetInput( reader->GetOutput() );
try
{
writer->UpdateLargestPossibleRegion();
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
1. How could I modify it in order to obtain the volume?
2. How could I modify it in order to use "itkImageToVTKImageFilter.h" to display it on vtk window?
Thank you a lot!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110517/18f1274a/attachment.htm>
More information about the Insight-users
mailing list