From 5d0dec8e4214bbb37d0229018ea26eab5ccabf0f Mon Sep 17 00:00:00 2001 From: Frederic Cervenansky Date: Thu, 5 May 2011 09:19:12 +0000 Subject: [PATCH] *** empty log message *** --- src/creaImageIOWxISimpleDlg.hpp | 96 +++++++++++++++------------------ 1 file changed, 44 insertions(+), 52 deletions(-) diff --git a/src/creaImageIOWxISimpleDlg.hpp b/src/creaImageIOWxISimpleDlg.hpp index 518ff93..2993b1e 100644 --- a/src/creaImageIOWxISimpleDlg.hpp +++ b/src/creaImageIOWxISimpleDlg.hpp @@ -10,9 +10,10 @@ #include #include #include -//#include "itkImageToVTKImageFilter.h" +#include #include #include +#include #include #include #include @@ -323,60 +324,51 @@ namespace creaImageIO { typename TImage::Pointer image = m_Iresults[0]; - // Size and dims for Input Image - typedef itk::Size<4> iSize; - typedef const itk::Size<4>::SizeValueType iSizeVal; - iSize size = image->GetLargestPossibleRegion().GetSize(); - iSizeVal *dims_size = size.GetSize(); - - // Output Type - typedef itk::Image ImageOutputType; - typedef itk::ImageSeriesWriter SeriesWriterType; - - /* typedef itk::VectorImage VectorImageType; - VectorImageType::Pointer vect = VectorImageType::New(); - vect.*/ - - - SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New(); - seriesWriter->SetInput( image); + if(image->GetImageDimension() == 4) + { + // size of fourth dimension + int dsize = image->GetLargestPossibleRegion().GetSize(3); + // Output Type + typedef itk::Image ImageOutputType; + typedef itk::ImageSeriesWriter SeriesWriterType; + typedef itk::MetaImageIO MetaImageType; + MetaImageType::Pointer metaIO; + SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New(); - // from JPR file to generate output files - typedef itk::NumericSeriesFileNames NamesGeneratorType; - NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New(); - namesGenerator->SetStartIndex(0); - namesGenerator->SetEndIndex(dims_size[3]-1); - namesGenerator->SetIncrementIndex(1); - std::string format = i_dir; - format += "/image%03d.vtk"; - namesGenerator->SetSeriesFormat( format.c_str() ); - const std::vector names = namesGenerator->GetFileNames(); - seriesWriter->SetFileNames( names ); - - try - { - seriesWriter->Update(); - vtkImageReader2 *vReader = vtkImageReader2::New(); - vReader->SetFilePrefix(".vtk"); - std::vector::const_iterator it = names.begin(); -// for(unsigned int i = 0 ;i < dims_size[3]; i++) - for( ;it != names.end(); ++it) + // from JPR file to generate output files + typedef itk::NumericSeriesFileNames NamesGeneratorType; + NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New(); + namesGenerator->SetStartIndex(0); + namesGenerator->SetEndIndex(dsize-1); + namesGenerator->SetIncrementIndex(1); + std::string format = i_dir; + format += "/image%03d.mhd"; + namesGenerator->SetSeriesFormat( format.c_str() ); + + const std::vector names = namesGenerator->GetFileNames(); + seriesWriter->SetFileNames( names ); + seriesWriter->SetInput(image); + seriesWriter->SetImageIO(metaIO); + try { - std::string name(*it); - vReader->SetFileName("d://temp2//image000.vtk");//name.c_str()); - vReader->Update(); - crea::VtkBasicSlicer(vReader->GetOutput()); - m_Vresults.push_back(vReader->GetOutput()); + seriesWriter->Update(); + vtkMetaImageReader *vReader = vtkMetaImageReader::New(); + std::vector::const_iterator it = names.begin(); + for( ;it != names.end(); ++it) + { + vReader->SetFileName((*it).c_str()); + vReader->Update(); + m_Vresults.push_back(vReader->GetOutput()); + } } - } - catch( itk::ExceptionObject & excp ) - { - std::cerr << "Exception thrown while writing the series " << std::endl; - std::cerr << excp << std::endl; - //return EXIT_FAILURE; - } - - } + catch( itk::ExceptionObject & excp ) + { + std::cerr << "Exception thrown while writing the series " << std::endl; + std::cerr << excp << std::endl; + //return EXIT_FAILURE; + } + } + } } -- 2.47.1