[Insight-users] RE : Mean image
Yankam Njiwa Josiane Adrienne
njiwa at biomed.ee.ethz.ch
Mon May 26 11:33:29 EDT 2008
Hi Cameron,
Thanks a lot for your answer, but i think my problem occured when i try to perfom division. Here is my complete code. I don't exactly how i can enter this division part in my pipeline. Do you have any idea?
Regards,
Josiane.
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::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() );
writer->SetFileName( argv[4] );
writer->SetInput( addition2->GetOutput()/3.0 );// I would like here to compute the mean between the three images
writer->Update();
return EXIT_SUCCESS;
________________________________
De: Cameron Burnett [mailto:w_e_b_m_a_s_t_e_r_6_9 at hotmail.com]
Date: lun. 26/05/2008 17:18
À: Yankam Njiwa Josiane Adrienne
Cc: insight-users at itk.org
Objet : RE: [Insight-users] Mean image
I'm not sure what the 'red' line is because I can't see any colour. Maybe the problem is that you haven't called Update() on your pipeline.
reader1 > addition1 > addition2 > Image
reader2 > addition1 > addition2 > Image
reader3 > addition2 > Image
Plugging in GetOutput() will set the links like above. EG: Reader3 goes to addition2 then to Image. If you do an Image->Update() then that will update everything thats linked to Image that is before it (all the links I typed above). Then you can actually use the image :).
What are you doing on this line? ImageType::Pointer Image1 =Image/3.0;
It seems like you're dividing the pointer by 3, and I'm fairly sure you don't want to do that. Maybe ImageType::Pointer Image1 =Image->GetOutput()/3.0; might do something?? In that case I think writer->Update() WILL update your whole pipeline, and that previous problem will be fixed also.
________________________________
> Date: Mon, 26 May 2008 17:01:33 +0200
> From: njiwa at biomed.ee.ethz.ch
> To: insight-users at itk.org
> Subject: [Insight-users] Mean image
>
>
>
> 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
________________________________
Email Australia. Be part of history. Take part in Australia's first e-mail archive with <http://emailaustralia.ninemsn.com.au/>
More information about the Insight-users
mailing list