[Insight-users] ITK example that sums multiple metaheader images

Luis Ibanez luis.ibanez at kitware.com
Thu Oct 16 08:08:46 EDT 2008


Hi Stéphane

It should be relatively straight forward to implement this.

Put the list of filenames in an array of std::strings called
"name" and do the following:


     reader->SetFileName( name[0] );
     reader->Update();
     ImageType::Pointer inputImage1 = reader->GetOutput();
     adder->SetInput1( inputImage1 );

     for( int i=0; i<numberOfFiles; i++)
       {
       reader->SetFileName( name[i] );
       reader->Update();
       ImageType::Pointer inputImage2 = reader->GetOutput();
       inputImage2->DisconnectPipeline();
       adder->SetInput2( inputImage2 );
       adder->Update();
       ImageType::Pointer sumImage = adder->GetOutput();
       sumImage->DisconnectPipeline();
       adder->SetInput1( sumImage );
       }

    // Here  sumImage has the output.


Note the use of the DisconnectPipeline() method, that
makes possible to reuse the reader and the adder filter.



Regards,


    Luis


-------------------------
Stéphane CALANDE wrote:
> Hi,
> 
> 
> I'm a newbie in ITK and I'm looking for a example of program that takes, 
> as input, several 3D metaheader image (.mhd) having the same spacing, 
> size,... and that "sums" these images to create one "total_Image.mhd" 
> having the same size, spacing,... than the input ones.
> 
> 
> Does it exist ?
> 
> 
> Thank you very much.
> 
> 
> 
> 
> Regards,
> 
> 
> Stéphane
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list