[Insight-users] Problem generating a 3D volume from a set of slices
Bill Lorensen
bill.lorensen at gmail.com
Wed May 18 00:02:45 EDT 2011
What are the names of the file? From your code they should be something
like:
Dora00001d.png
Dora00002d.png
Dora00003d.png
...
Is that how your files are named?
Bill
On Tue, May 17, 2011 at 4:19 PM, Dora Szasz <dora.szasz at yahoo.com> wrote:
> 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!
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110518/ced277b6/attachment.htm>
More information about the Insight-users
mailing list