[Insight-users] RE : Mean image

Yankam Njiwa Josiane Adrienne njiwa at biomed.ee.ethz.ch
Tue May 27 04:31:26 EDT 2008


Hi Bill,
 
Thank you for your help and sorry to come back again. I used the itkNaryAddFilter you advice to me to add images but when i run the programme, it cannot work, the error is:Debug error, this appliaction has request the Runtime to terminate it in an unusual way. I don't know exactly what i did wrong.
 
For the itkShiftScaleImageFilter, i have no idea on how to use it. Do you have an example which can help me please?
 
The pipeline i implemented for the itkNaryAddFilter is written bellow.
 
Thanks a lot,
 
Josiane
 
 
#include "itkImage.h"

#include "itkImageFileReader.h"

#include "itkImageFileWriter.h"

#include "itkAddImageFilter.h"

#include "itkImageIOBase.h"

#include "itkNaryAddImageFilter.h"

int main( int argc, char * argv[] )

{

if( argc < 5 )

{

std::cerr << "Usage: " << std::endl;

std::cerr << argv[0] << " Image1 Image2 Image3 outputImage" << std::endl;

return EXIT_FAILURE;

}

 

typedef float PixelType;

typedef itk::Image< PixelType, 3 > ImageType;

typedef itk::ImageFileReader< ImageType > ReaderType;

typedef itk::ImageFileWriter< ImageType > WriterType;

ReaderType::Pointer reader1 = ReaderType::New();

ReaderType::Pointer reader2 = ReaderType::New();

ReaderType::Pointer reader3 = ReaderType::New();

WriterType::Pointer writer = WriterType::New();

reader1->SetFileName( argv[1] );

reader2->SetFileName( argv[2] );

reader3->SetFileName( argv[3] );

writer->SetFileName( argv[4] );

reader1->Update();

reader2->Update();

reader3->Update();

typedef itk::NaryAddImageFilter< 

ImageType, 

ImageType > NAddFilterType;

NAddFilterType::Pointer addition = NAddFilterType::New();

addition->SetInput( reader1->GetOutput() );

addition->SetInput( reader2->GetOutput() );

addition->SetInput( reader3->GetOutput() );

addition-> Update();

writer->SetFileName( argv[4] );

writer->SetInput(addition->GetOutput());

writer->Update();

return EXIT_SUCCESS;


________________________________

De: Bill Lorensen [mailto:bill.lorensen at gmail.com]
Date: lun. 26/05/2008 22:16
À: Yankam Njiwa Josiane Adrienne
Cc: insight-users at itk.org
Objet : Re: [Insight-users] Mean image



You can add "N" images with itkNaryAddImageFilter, then divide by 3
with itkShiftScaleImageFilter.

On Mon, May 26, 2008 at 11:01 AM, Yankam Njiwa  Josiane Adrienne
<njiwa at biomed.ee.ethz.ch> wrote:
>
>
> Dear all,
>
> I would like to compute the mean between 3 images. I used the code bollow but the line in red seems to be false and i don't understand why. Could somebody help me please?
>
> Regards,
>
> Josiane.
>
>
>
>
>
> typedef itk::AddImageFilter<
>
> ImageType,
>
> ImageType,
>
> ImageType > AdditionFilterType;
>
> AdditionFilterType::Pointer addition1 = AdditionFilterType::New();
>
> AdditionFilterType::Pointer addition2 = AdditionFilterType::New();
>
> addition1->SetInput1( reader1->GetOutput() );
>
> addition1->SetInput2( reader2->GetOutput() );
>
> addition2->SetInput1( reader3->GetOutput() );
>
> addition2->SetInput2( addition1->GetOutput() );
>
> ImageType::Pointer Image = addition2->GetOutput();
>
> ImageType::Pointer Image1 =Image/3.0;
>
> writer->SetFileName( argv[4] );
>
> writer->SetInput( Image1 );
>
> writer->Update();
>
> _______________________________________________
> 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