Hi,<br><br>I am a newbie to ITK. I was trying to read a set of dicom images from a directory and then use reader->update() to process each one of them one after the other. But the reader->update() gives me an error after reading the first image. Can anyone please tell me how to fix this problem?
<br><br>This is what my code looks like. It is not the complete code, but only the relevant part of it.<br>---------------<br> typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br> NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
<br> nameGenerator->SetInputDirectory( "D:\\testimages" );<br><br> typedef std::vector<std::string> FileNamesContainer;<br> FileNamesContainer fileNames = nameGenerator->GetInputFileNames();<br>
unsigned int numberOfFilenames =
fileNames.size();<br> std::cout << numberOfFilenames << std::endl; <br> unsigned int fni;<br><br> for(fni = 0; fni<numberOfFilenames; fni++)<br> {<br> std::cout << "filename # " << fni << " = ";
<br> std::cout << fileNames[fni] << std::endl;<br> }<br><br> for(fni = 0; fni<numberOfFilenames; fni++)<br> {<br> reader->SetFileName( fname);<br><br> reader->SetImageIO( gdcmImageIO );<br>
<br>
try<br> {<br> reader->Update();//this is where it gives me an error second time in the loop.<br> }<br> catch (itk::ExceptionObject & e)<br> {<br> std::cerr << "exception in file reader " << std::endl;
<br> std::cerr << e << std::endl;<br> return EXIT_FAILURE;<br> }<br>// code for processing the image //<br>//code for writing the processed image//<br>}// for loop complete<br>--------------------------------------
<br>The filenames are correctly read, the code runs fine the first time through the for loop, but second time it gives an error at the reader->Update() line.<br>Can anyone please tell me why is this happening and how to fix it?
<br><br>Thanks,<br>Ashish<br><br><br>