[Insight-users] Problem generating a 3D volume from a set of slices

Bill Lorensen bill.lorensen at gmail.com
Wed May 18 08:00:16 EDT 2011


But the program should be run as:
BrainModel.exe 1 5 out.mhd

at least according to the source you attached.

On Wed, May 18, 2011 at 2:00 AM, Dora Szasz <dora.szasz at yahoo.com> wrote:

> Hi Bill,
>
> Yes, the names of the files are correct, but the following  error message
> appears:
> I have verified and the size of the pictures is the same. I don't know what
> could be the problem.
> Thank you!
>
> *D:\Lib\Project\Dora\bin\Debug>BrainModel.exe Dora0001d.png Dora0005d.png
> out.mhd*
> *ExceptionObject caught !*
> *
> *
> *itk::ExceptionObject (00B2F4D8)*
> *Location: "void __thiscall itk::ImageFileWriter<class itk::Image<unsigned
> char,3*
> *> >::Write(void)"*
> *File: d:\lib\_itk\source\code\io\itkImageFileWriter.txx*
> *Line: 271*
> *Description: itk::ERROR: ImageFileWriter(0012F3F8): Largest possible
> region does*
> * not fully contain requested paste IO regionPaste IO region:
> ImageIORegion (00B2*
> *F910)*
> *  Dimension: 3*
> *  Index: 0 0 0*
> *  Size: 0 0 1*
> *Largest possible region: ImageRegion (00B2F9C4)*
> *  Dimension: 3*
> *  Index: [0, 0, 0]*
> *  Size: [0, 0, 1]*
>
> ------------------------------
> *From:* Bill Lorensen <bill.lorensen at gmail.com>
> *To:* Dora Szasz <dora.szasz at yahoo.com>
> *Cc:* "insight-users at itk.org" <insight-users at itk.org>
> *Sent:* Wednesday, May 18, 2011 7:03 AM
> *Subject:* Re: [Insight-users] Problem generating a 3D volume from a set
> of slices
>
> Oops...
> Dora0001d.png
> Dora0002d.png
> Dora0003d.png
> ...
>
>
> On Wed, May 18, 2011 at 12:02 AM, Bill Lorensen <bill.lorensen at gmail.com>wrote:
>
> 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/88ee228d/attachment.htm>


More information about the Insight-users mailing list