Hi agatte,<div><br></div><div>I am wondering the problem is related the "<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">outputFilename"</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-></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 = "volume3Dtest.mhd";</div><div> WriterType::Pointer writer = WriterType::New();</div>
<div> writer->SetFileName( outputFilename );</div><div> writer->SetInput( reader->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"><<a href="mailto:wiatrak11@poczta.onet.pl" target="_blank">wiatrak11@poczta.onet.pl</a>></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'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 "itkImage.h"<br>
#include "itkImageSeriesReader.h"<br>
#include "itkImageFileWriter.h"<br>
#include "itkNumericSeriesFileNames.h"<br>
#include "itkTIFFImageIO.h"<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< PixelType, Dimension > ImageType;<br>
typedef itk::ImageSeriesReader< ImageType > ReaderType;<br>
typedef itk::ImageFileWriter< ImageType > WriterType;<br>
<br>
ReaderType::Pointer reader = ReaderType::New();<br>
WriterType::Pointer writer = WriterType::New();<br>
<br>
reader->SetImageIO( itk::TIFFImageIO::New() );<br>
<br>
ImageType::ConstPointer volume = reader->GetOutput();<br>
ImageType::RegionType volumeRegion = volume->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 = "volume3Dtest.vtk";<br>
<br>
typedef itk::NumericSeriesFileNames NameGeneratorType;<br>
NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();<br>
nameGenerator->SetSeriesFormat( "C:\\data\\series\\File%03d.tiff" );<br>
<br>
nameGenerator->SetStartIndex( firstImage );<br>
nameGenerator->SetEndIndex( lastImage );<br>
<br>
// take every two/second image<br>
nameGenerator->SetIncrementIndex(2);<br>
<br>
reader->SetImageIO( itk::TIFFImageIO::New() );<br>
reader->SetFileNames( nameGenerator->GetFileNames() );<br>
<br>
writer->SetFileName( outputFilename );<br>
<br>
writer->SetInput( reader->GetOutput() );<br>
<br>
try<br>
{<br>
writer->Update();<br>
}<br>
catch( itk::ExceptionObject & err )<br>
{<br>
std::cerr << "ExceptionObject caught !" << std::endl;<br>
std::cerr << err << 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>