[Insight-users] Cannot Read ImageSeries and save as 3D Volume

Erkang Cheng ekyaya at gmail.com
Fri Jul 20 10:02:54 EDT 2012


Hi agatte,

I am wondering the problem is related the "outputFilename".

Could you try changing the following modification :
           nameGenerator->SetIncrementIndex(1);

Also, you can try to use metaIO to save volume which is simplest.

  const char * outputFilename = "volume3Dtest.mhd";
  WriterType::Pointer writer = WriterType::New();
  writer->SetFileName( outputFilename );
  writer->SetInput( reader->GetOutput() );


Best
Erkang


On Fri, Jul 20, 2012 at 8:57 AM, agatte <wiatrak11 at poczta.onet.pl> wrote:

>
> Hi All ;)
>
> I am trying to read image series and save as a Volume.
> But I wantn't   to set fixed first and last image.
> Size depends on the Image Series.
> I used this example :
> http://www.itk.org/Wiki/ITK/Examples/IO/VolumeFromSlices
>
> I have already modified this code  but it is going wrong ;/
>
> #include "itkImage.h"
> #include "itkImageSeriesReader.h"
> #include "itkImageFileWriter.h"
> #include "itkNumericSeriesFileNames.h"
> #include "itkTIFFImageIO.h"
>
> int main( int argc, char ** argv )
> {
>
>   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();
>
>   reader->SetImageIO( itk::TIFFImageIO::New() );
>
>   ImageType::ConstPointer  volume = reader->GetOutput();
>   ImageType::RegionType volumeRegion = volume->GetLargestPossibleRegion();
>   ImageType::IndexType start = volumeRegion.GetIndex();
>   ImageType::SizeType size = volumeRegion.GetSize();
>
>   const unsigned int firstImage = start[2];
>   const unsigned int lastImage  = start[2] + size[2] - 1;
>
>   const char * outputFilename = "volume3Dtest.vtk";
>
>   typedef itk::NumericSeriesFileNames    NameGeneratorType;
>   NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
>   nameGenerator->SetSeriesFormat( "C:\\data\\series\\File%03d.tiff" );
>
>   nameGenerator->SetStartIndex( firstImage );
>   nameGenerator->SetEndIndex( lastImage );
>
>   // take every two/second image
>   nameGenerator->SetIncrementIndex(2);
>
>  reader->SetImageIO( itk::TIFFImageIO::New() );
>   reader->SetFileNames( nameGenerator->GetFileNames()  );
>
>   writer->SetFileName( outputFilename );
>
>   writer->SetInput( reader->GetOutput() );
>
>   try
>     {
>     writer->Update();
>     }
>   catch( itk::ExceptionObject & err )
>     {
>     std::cerr << "ExceptionObject caught !" << std::endl;
>     std::cerr << err << std::endl;
>     return EXIT_FAILURE;
>     }
>
>
>   return EXIT_SUCCESS;
> }
>
>
> I would appreciate for any help please.
>
>
> Best,
> agatte
> --
> View this message in context:
> http://old.nabble.com/Cannot-Read-ImageSeries-and-save-as-3D-Volume-tp34189755p34189755.html
> Sent from the ITK - Users mailing list archive at Nabble.com.
>
> _____________________________________
> 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.php
>
> 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/20120720/4f1400d9/attachment.htm>


More information about the Insight-users mailing list