<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Hello all,</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">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.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">My code is the following:</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">#include "itkImage.h"</font></div><div><font class="Apple-style-span" face="'times new
roman', 'new york', times, serif"> #include "itkImageSeriesReader.h"</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> #include "itkImageFileWriter.h"</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> #include "itkNumericSeriesFileNames.h"</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> #include "itkPNGImageIO.h"</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> int main( int argc, char ** argv )</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> {</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> // Verify the number of
parameters in the command line</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> if( argc < 4 )</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> {</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> std::cerr << "Usage: " << std::endl;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> std::cerr << argv[0] << " firstSliceValue lastSliceValue outputImageFile " << std::endl;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> return EXIT_FAILURE;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> }</font></div><div><font class="Apple-style-span" face="'times new
roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> typedef unsigned char PixelType;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> const unsigned int Dimension = 3;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> typedef itk::Image< PixelType, Dimension > ImageType;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> typedef itk::ImageSeriesReader< ImageType > ReaderType;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> typedef itk::ImageFileWriter< ImageType >
WriterType;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> ReaderType::Pointer reader = ReaderType::New();</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> WriterType::Pointer writer = WriterType::New();</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> const unsigned int first = atoi( argv[1] );</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> const unsigned int last = atoi( argv[2] );</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font
class="Apple-style-span" face="'times new roman', 'new york', times, serif"> const char * outputFilename = argv[3];</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> typedef itk::NumericSeriesFileNames NameGeneratorType;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> nameGenerator->SetSeriesFormat( "Dora00%02d.png" );</font></div><div><font
class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> nameGenerator->SetStartIndex( first );</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> nameGenerator->SetEndIndex( last );</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> nameGenerator->SetIncrementIndex( 1 );</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> reader->SetImageIO( itk::PNGImageIO::New() );</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> reader->SetFileNames( nameGenerator->GetFileNames()
);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> writer->SetFileName( outputFilename );</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> writer->SetInput( reader->GetOutput() );</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> try</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> {</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> writer->UpdateLargestPossibleRegion();</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> writer->Update();</font></div><div><font
class="Apple-style-span" face="'times new roman', 'new york', times, serif"> }</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> catch( itk::ExceptionObject & err )</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> {</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> std::cerr << "ExceptionObject caught !" << std::endl;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> std::cerr << err << std::endl;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> return EXIT_FAILURE;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> }</font></div><div><font
class="Apple-style-span" face="'times new roman', 'new york', times, serif"> return EXIT_SUCCESS;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"> }</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">1. How could I modify it in order to obtain the volume?</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">2. How could I modify it in order to use "itkImageToVTKImageFilter.h" to display it on vtk window?</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">Thank you a lot!</font></div></div><div style="font-family: 'times new roman', 'new york',
times, serif; font-size: 12pt; "><br></div></div></body></html>