Hi agatte,<div><br></div><div>I am wondering the problem is related the &quot;<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">outputFilename&quot;</span>.</div>
<div><br></div><div>Could you try changing the following modification :</div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">           nameGenerator-&gt;</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">SetIncrementIndex(1);</span><span style="background-color:rgb(255,255,255)"> </span></div>
<div><span style="background-color:rgb(255,255,255)"><br></span></div><div><span style="background-color:rgb(255,255,255)">Also, you can try to use metaIO to save volume which is simplest.</span></div><div><span style="background-color:rgb(255,255,255)"><br>
</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">  </span>const char * outputFilename = &quot;volume3Dtest.mhd&quot;;</div><div>  WriterType::Pointer writer = WriterType::New();</div>
<div>  writer-&gt;SetFileName( outputFilename );</div><div>  writer-&gt;SetInput( reader-&gt;GetOutput() );</div><div><span style="background-color:rgb(255,255,153)"><br></span></div><div><span style="background-color:rgb(255,255,153)"><br>
</span></div><div><span style="background-color:rgb(255,255,255)">Best</span></div><div><span style="background-color:rgb(255,255,255)">Erkang</span></div><div><br><br><div class="gmail_quote">On Fri, Jul 20, 2012 at 8:57 AM, agatte <span dir="ltr">&lt;<a href="mailto:wiatrak11@poczta.onet.pl" target="_blank">wiatrak11@poczta.onet.pl</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi All ;)<br>
<br>
I am trying to read image series and save as a Volume.<br>
But I wantn&#39;t   to set fixed first and last image.<br>
Size depends on the Image Series.<br>
I used this example :<br>
<a href="http://www.itk.org/Wiki/ITK/Examples/IO/VolumeFromSlices" target="_blank">http://www.itk.org/Wiki/ITK/Examples/IO/VolumeFromSlices</a><br>
<br>
I have already modified this code  but it is going wrong ;/<br>
<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>
<br>
int main( int argc, char ** argv )<br>
{<br>
<br>
  typedef unsigned char                       PixelType;<br>
  const unsigned int Dimension = 3;<br>
<br>
  typedef itk::Image&lt; PixelType, Dimension &gt;  ImageType;<br>
  typedef itk::ImageSeriesReader&lt; ImageType &gt;  ReaderType;<br>
  typedef itk::ImageFileWriter&lt;   ImageType &gt;  WriterType;<br>
<br>
  ReaderType::Pointer reader = ReaderType::New();<br>
  WriterType::Pointer writer = WriterType::New();<br>
<br>
  reader-&gt;SetImageIO( itk::TIFFImageIO::New() );<br>
<br>
  ImageType::ConstPointer  volume = reader-&gt;GetOutput();<br>
  ImageType::RegionType volumeRegion = volume-&gt;GetLargestPossibleRegion();<br>
  ImageType::IndexType start = volumeRegion.GetIndex();<br>
  ImageType::SizeType size = volumeRegion.GetSize();<br>
<br>
  const unsigned int firstImage = start[2];<br>
  const unsigned int lastImage  = start[2] + size[2] - 1;<br>
<br>
  const char * outputFilename = &quot;volume3Dtest.vtk&quot;;<br>
<br>
  typedef itk::NumericSeriesFileNames    NameGeneratorType;<br>
  NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();<br>
  nameGenerator-&gt;SetSeriesFormat( &quot;C:\\data\\series\\File%03d.tiff&quot; );<br>
<br>
  nameGenerator-&gt;SetStartIndex( firstImage );<br>
  nameGenerator-&gt;SetEndIndex( lastImage );<br>
<br>
  // take every two/second image<br>
  nameGenerator-&gt;SetIncrementIndex(2);<br>
<br>
 reader-&gt;SetImageIO( itk::TIFFImageIO::New() );<br>
  reader-&gt;SetFileNames( nameGenerator-&gt;GetFileNames()  );<br>
<br>
  writer-&gt;SetFileName( outputFilename );<br>
<br>
  writer-&gt;SetInput( reader-&gt;GetOutput() );<br>
<br>
  try<br>
    {<br>
    writer-&gt;Update();<br>
    }<br>
  catch( itk::ExceptionObject &amp; err )<br>
    {<br>
    std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl;<br>
    std::cerr &lt;&lt; err &lt;&lt; std::endl;<br>
    return EXIT_FAILURE;<br>
    }<br>
<br>
<br>
  return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
I would appreciate for any help please.<br>
<br>
<br>
Best,<br>
agatte<br>
--<br>
View this message in context: <a href="http://old.nabble.com/Cannot-Read-ImageSeries-and-save-as-3D-Volume-tp34189755p34189755.html" target="_blank">http://old.nabble.com/Cannot-Read-ImageSeries-and-save-as-3D-Volume-tp34189755p34189755.html</a><br>

Sent from the ITK - Users mailing list archive at Nabble.com.<br>
<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br></div>