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

Bill Lorensen bill.lorensen at gmail.com
Wed May 18 12:28:45 EDT 2011


I you remove the UpdateLargestPossibleRegion and just use writer->Update()
you will probably get a more descriptive exception description.


On Wed, May 18, 2011 at 12:12 PM, Bill Lorensen <bill.lorensen at gmail.com>wrote:

> I suspect that it is not finding the files. Show me the exact command line
> you are using to run your program. Also provide a directory listing of the
> directory containing the files.
>
> The names generator generates names, it does not check to see if the names
> are valid files.
>
> On Wed, May 18, 2011 at 11:54 AM, Bill Lorensen <bill.lorensen at gmail.com>wrote:
>
>> Dora,
>> Can you send to me the 5 png files? I just built an example similar to
>> yours and it works.
>>
>> Bill
>>
>>
>> On Wed, May 18, 2011 at 11:10 AM, Dora Szasz <dora.szasz at yahoo.com>wrote:
>>
>>> Ok. Thank you a lot!
>>>
>>> ------------------------------
>>> *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 5:30 PM
>>>
>>> *Subject:* Re: [Insight-users] Problem generating a 3D volume from a set
>>> of slices
>>>
>>> I'll try to reproduce the problem. Probably not until later though.
>>>
>>> On Wed, May 18, 2011 at 10:12 AM, Dora Szasz <dora.szasz at yahoo.com>wrote:
>>>
>>> Yes. Exactly the same one.
>>>
>>> ------------------------------
>>> *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 5:06 PM
>>>
>>> *Subject:* Re: [Insight-users] Problem generating a 3D volume from a set
>>> of slices
>>>
>>> Do you get the same exception message?
>>>
>>> On Wed, May 18, 2011 at 9:07 AM, Dora Szasz <dora.szasz at yahoo.com>wrote:
>>>
>>> It writes me the name of the files, but no .mhd ouput file.
>>>
>>> File: Dora0001.png
>>> File: Dora0002.png
>>> File: Dora0003.png
>>> File: Dora0004.png
>>> File: Dora0005.png
>>>
>>> ------------------------------
>>> *From:* Bill Lorensen <bill.lorensen at gmail.com>
>>> *To:* Dora Szasz <dora.szasz at yahoo.com>
>>> *Cc:* Insight-Users <insight-users at itk.org>
>>> *Sent:* Wednesday, May 18, 2011 3:27 PM
>>>
>>> *Subject:* Re: [Insight-users] Problem generating a 3D volume from a set
>>> of slices
>>>
>>> [please keep the mailing list involved]
>>> Try printing out the generated filenames. Something like:
>>>
>>>   std::vector<std::string> names = nameGenerator->GetFileNames();
>>>   std::vector<std::string>::iterator nit;
>>>
>>>   for (nit = names.begin();
>>>        nit != names.end();
>>>        nit++)
>>>     {
>>>     std::cout << "File: " << (*nit).c_str() << std::endl;
>>>     }
>>>
>>>
>>>
>>>
>>> On Wed, May 18, 2011 at 8:16 AM, Dora Szasz <dora.szasz at yahoo.com>wrote:
>>>
>>> I've tried all the possibilities. Even if I run BrainModel.exe 1 5
>>> out.mhd the error appears and I don't know why.
>>>
>>> ------------------------------
>>> *From:* Bill Lorensen <bill.lorensen at gmail.com>
>>> *To:* Dora Szasz <dora.szasz at yahoo.com>
>>> *Cc:* Insight-Users <insight-users at itk.org>
>>> *Sent:* Wednesday, May 18, 2011 3:00 PM
>>>
>>> *Subject:* Re: [Insight-users] Problem generating a 3D volume from a set
>>> of slices
>>>
>>> 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/911e4f4c/attachment.htm>


More information about the Insight-users mailing list