[Insight-users] question ? [Iterators into image series]
agatte
wiatrak11 at poczta.onet.pl
Wed Jul 18 09:38:22 EDT 2012
Hi All ITK Users ;)
I am fresh user.
I want to extract each slice with two neighbors from image series.
For example for second slice it will be 1,2,3 and save it as volume.
I will have to be in a loop.
Maybe do You have any idea or good solution for this problem ?
I would appreciate for any help please.
Here I have already created function for extract odd slices from series and
save as volume.
int ReadSeriesCreateVolumeP(std::string series, const char * outputVolume1P)
{
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("0");
const unsigned int last = atoi("127");
typedef itk::NumericSeriesFileNames NameGeneratorType;
NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
nameGenerator->SetSeriesFormat( series );
nameGenerator->SetStartIndex( first );
nameGenerator->SetEndIndex( last );
nameGenerator->SetIncrementIndex(2);
reader->SetImageIO( itk::TIFFImageIO::New() );
reader->SetFileNames( nameGenerator->GetFileNames() );
writer->SetFileName(outputVolume1P);
writer->SetInput( reader->GetOutput() );
try
{
writer->Update();
std::cout << " 3d Volume saved ! " <<std::endl;
}
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.
agatte ;)
--
View this message in context: http://old.nabble.com/question----Iterators-into-image-series--tp34179149p34179149.html
Sent from the ITK - Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list