I'm new to ITK and I'm currently having problems assemble my series of Tiff files into a vtkImage. I've simply edited the PNGSeriesWriter example. A vtk image does get generated, and I've managed to load it in VolView and MicroView by using ITK 
2.4.1. However, when I look at the volume, the whole volume is composed of only the first Tiff file , and is repeated along the z axis. <br><br>Anyone know how to fix this? Help is greatly appreciated. I've pasted my code below.
<br><br>Jon<br><br>/*=========================================================================<br><br>&nbsp; Program:&nbsp;&nbsp; Insight Segmentation &amp; Registration Toolkit<br>&nbsp; Module:&nbsp;&nbsp;&nbsp; $RCSfile: ImageSeriesReadWrite.cxx,v $<br>
&nbsp; Language:&nbsp; C++<br>&nbsp; Date:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Date: 2005/11/20 13:27:53 $<br>&nbsp; Version:&nbsp;&nbsp; $Revision: 1.10 $<br><br>&nbsp; Copyright (c) Insight Software Consortium. All rights reserved.<br>&nbsp; See ITKCopyright.txt or <a href="http://www.itk.org/HTML/Copyright.htm">
http://www.itk.org/HTML/Copyright.htm</a> for details.<br><br>&nbsp;&nbsp;&nbsp;&nbsp; This software is distributed WITHOUT ANY WARRANTY; without even <br>&nbsp;&nbsp;&nbsp;&nbsp; the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR <br>&nbsp;&nbsp;&nbsp;&nbsp; PURPOSE.&nbsp; See the above copyright notices for more information.
<br><br>=========================================================================*/<br>#if defined(_MSC_VER)<br>#pragma warning ( disable : 4786 )<br>#endif<br><br>#ifdef __BORLANDC__<br>#define ITK_LEAN_AND_MEAN<br>#endif
<br><br>//&nbsp; Software Guide : BeginLatex<br>//<br>//&nbsp; This example illustrates how to read a series of 2D slices from independent<br>//&nbsp; files in order to compose a volume. The class \doxygen{ImageSeriesReader}<br>//&nbsp; is used for this purpose. This class works in combination with a generator
<br>//&nbsp; of filenames that will provide a list of files to be read. In this<br>//&nbsp; particular example we use the \doxygen{NumericSeriesFileNames} class as<br>//&nbsp; filename generator. This generator uses a \code{printf} style of string format
<br>//&nbsp; with a ``\code{\%d}'' field that will be successively replaced by a number specified<br>//&nbsp; by the user. Here we will use a format like ``\code{file\%03d.png}'' for reading <br>//&nbsp; PNG files named file001.png, file002.png
, file003.png... and so on.<br>//<br>//&nbsp; This requires the following headers as shown.<br>//<br>//&nbsp; \index{itk::ImageSeriesReader!header}<br>//&nbsp; \index{itk::NumericSeriesFileNames!header}<br>//<br>//&nbsp; Software Guide : EndLatex 
<br><br>// Software Guide : BeginCodeSnippet<br>#include &quot;itkImage.h&quot;<br>#include &quot;itkImageSeriesReader.h&quot;<br>#include &quot;itkImageFileWriter.h&quot;<br>#include &quot;itkNumericSeriesFileNames.h&quot;
<br>#include &quot;itkTIFFImageIO.h&quot;<br>// Software Guide : EndCodeSnippet<br><br><br>int main( int argc, char ** argv )<br>{<br>&nbsp; // Verify the number of parameters in the command line<br>&nbsp; if( argc &lt; 4 )<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; argv[0] &lt;&lt; &quot; firstSliceValue lastSliceValue&nbsp; outputImageFile &quot; &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>
&nbsp;&nbsp;&nbsp; }<br><br><br>// Software Guide : BeginLatex<br>//<br>// We start by defining the \code{PixelType} and \code{ImageType}.<br>//<br>//<br>// Software Guide : EndLatex <br><br>// Software Guide : BeginCodeSnippet<br>&nbsp; typedef unsigned char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PixelType;
<br>&nbsp; const unsigned int Dimension = 3;<br><br>&nbsp; typedef itk::Image&lt; PixelType, Dimension &gt;&nbsp; ImageType;<br><br>&nbsp; typedef itk::ImageSeriesReader&lt; ImageType &gt;&nbsp; ReaderType;<br>&nbsp; typedef itk::ImageFileWriter&lt;&nbsp;&nbsp; ImageType &gt;&nbsp; WriterType;
<br><br>&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>&nbsp; WriterType::Pointer writer = WriterType::New();<br><br>&nbsp; const unsigned int first = atoi( argv[1] );<br>&nbsp; const unsigned int last&nbsp; = atoi( argv[2] );<br><br>&nbsp; const char * outputFilename = argv[3];
<br><br><br>&nbsp; typedef itk::NumericSeriesFileNames&nbsp;&nbsp;&nbsp; NameGeneratorType;<br><br>&nbsp; NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();<br><br>&nbsp; nameGenerator-&gt;SetSeriesFormat( &quot;vol%03d.tiff&quot; ); //set file name imageformat here
<br><br>&nbsp; nameGenerator-&gt;SetStartIndex( first );<br>&nbsp; nameGenerator-&gt;SetEndIndex( last );<br>&nbsp; nameGenerator-&gt;SetIncrementIndex( 1 );<br><br>&nbsp; reader-&gt;SetImageIO( itk::TIFFImageIO::New() );<br><br>&nbsp; reader-&gt;SetFileNames( nameGenerator-&gt;GetFileNames()&nbsp; );
<br>&nbsp; <br>&nbsp; writer-&gt;SetFileName( outputFilename );<br><br>&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; reader-&gt;Update();<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; catch( itk::ExceptionObject &amp; err ) <br>&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl; 
<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>/*<br>&nbsp; // JW: Get Image set spacing<br>&nbsp; ImageType::Pointer image = reader-&gt;GetOutput();<br><br>&nbsp; ImageType::SpacingType spacing;
<br><br>&nbsp; // Note: measurement units (in this application it's in mm)<br>&nbsp; spacing[0] = 0.021; // spacing along X<br>&nbsp; spacing[1] = 0.021; // spacing along Y<br>&nbsp; spacing[2] = 0.022; // spacing along Z<br><br><br>&nbsp; image-&gt;SetSpacing( spacing );
<br><br>&nbsp; ImageType::PointType origin;<br><br>&nbsp; origin[0] = 0.0;&nbsp; // coordinates of the <br>&nbsp; origin[1] = 0.0;&nbsp; // first pixel in N-D<br>&nbsp; origin[2] = 0.0;<br><br>&nbsp; image-&gt;SetOrigin( origin );<br><br>&nbsp; const ImageType::SpacingType&amp; sp = image-&gt;GetSpacing();&nbsp; 
<br><br>&nbsp; std::cout &lt;&lt; &quot;Spacing = &quot;;<br>&nbsp; std::cout &lt;&lt; sp[0] &lt;&lt; &quot;, &quot; &lt;&lt; sp[1] &lt;&lt; &quot;, &quot; &lt;&lt; sp[2] &lt;&lt; std::endl;<br><br>&nbsp; writer-&gt;SetInput( image );<br>
// Software Guide : EndCodeSnippet<br>&nbsp; */&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; writer-&gt;SetInput(reader-&gt;GetOutput());<br><br>&nbsp; try <br>&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp; writer-&gt;Update();<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; } <br>&nbsp; catch( itk::ExceptionObject &amp; err ) <br>&nbsp;&nbsp;&nbsp; { 
<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl; <br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp; } <br>// Software Guide : EndCodeSnippet<br><br><br>
&nbsp; return EXIT_SUCCESS;<br>}<br><br><br><br><br>