<div dir="ltr">Hi,<br><br>Thank you very much for your response Luis.<br>Meanwhile, I've used the NaryAddImageFilter to resolve my problem.<br>Here is the code for those that could be interrested in the subject :<br><br>
<br><br><br><br> #include "itkImage.h"<br> #include "itkImageFileReader.h"<br> #include "itkImageFileWriter.h"<br> #include "itkAddImageFilter.h"<br> #include "itkImageIOBase.h"<br>
#include "itkNaryAddImageFilter.h"<br><br> int main( int argc, char * argv[] )<br><br> {<br><br> if( argc < 4 )<br><br> {<br><br> std::cerr << "Usage: " << std::endl;<br><br> std::cerr << argv[0] << " Image1 Image2 [ImageX]* ImageOutput" << std::endl;<br>
<br> return EXIT_FAILURE;<br><br> }<br><br> typedef unsigned int PixelType; // be sure it's the good type !!<br> <br> typedef itk::Image< PixelType, 3 > ImageType;<br> <br> typedef itk::ImageFileReader< ImageType > ReaderType;<br>
<br> typedef itk::ImageFileWriter< ImageType > WriterType;<br><br> typedef itk::NaryAddImageFilter< ImageType,<br> ImageType > AddFilterType;<br> <br> int nbImages = argc - 2;<br>
<br> ReaderType::Pointer reader = ReaderType::New();<br> <br> AddFilterType::Pointer addition = AddFilterType::New();<br> <br> std::cout << std::endl;<br> <br> for (int i = 0 ; i < nbImages ; i++)<br>{ <br> reader->SetFileName( argv[i+1] );<br>
reader->Update();<br> addition->SetInput( i , reader->GetOutput() );<br> std::cout << "Image n°" << i+1 << " [" << argv[i+1] << "] added" << std::endl << std::endl;<br>
}<br><br> addition-> Update();<br><br> WriterType::Pointer writer = WriterType::New();<br> <br> writer->SetFileName( argv[nbImages+1] );<br><br> writer->SetInput(addition->GetOutput());<br><br> std::cout << "Writing file..." << std::endl << std::endl;<br>
<br> writer->Update();<br> <br> std::cout << "File '" << argv[nbImages+1] << "' created" << std::endl;<br><br> return EXIT_SUCCESS;<br> <br> }<br><br><br><br><br><br>
<br><br>Bye,<br><br><br><br>Stéphane<br></div>