Thank you very much for your help Dan,<br><br><br>I tried "MeanImageFilter" but I'm not sure I can calculate the mean of several images.<br>In fact, the functions SetInput1, SetInput2,... don't exist for MeanImageFilter...<br>
<br>Do you have some advice ?<br><br><br>Meanwhile, I'm going to try the DivideImageFilter.<br><br><br><br>Thank you in advance,<br><br><br><br>Stéphane<br><br><br><br><br><div class="gmail_quote">2008/10/22 Dan Mueller <span dir="ltr"><<a href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Stéphane,<br>
<br>
You probably want the MeanImageFilter:<br>
<a href="http://www.itk.org/Doxygen/html/classitk_1_1MeanImageFilter.html" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1MeanImageFilter.html</a><br>
<br>
You can use it in the same way as the add image filter that Luis<br>
described in his reply to your original question.<br>
<div class="Ih2E3d"><br>
reader->SetFileName( name[0] );<br>
reader->Update();<br>
ImageType::Pointer inputImage1 = reader->GetOutput();<br>
</div> mean->SetInput1( inputImage1 );<br>
<br>
for( int i=1; i<numberOfFiles; i++)<br>
<div class="Ih2E3d"> {<br>
reader->SetFileName( name[i] );<br>
reader->Update();<br>
ImageType::Pointer inputImage2 = reader->GetOutput();<br>
inputImage2->DisconnectPipeline();<br>
</div> mean>SetInput2( inputImage2 );<br>
mean->Update();<br>
<div class="Ih2E3d"> ImageType::Pointer sumImage = adder->GetOutput();<br>
</div> meanImage->DisconnectPipeline();<br>
mean->SetInput1( meanImage );<br>
}<br>
<br>
// Here meanImage has the output.<br>
<br>
Alternatively, you could use the DivideImageFilter after you have<br>
computed the sum:<br>
<a href="http://www.itk.org/Doxygen/html/classitk_1_1DivideImageFilter.html" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1DivideImageFilter.html</a><br>
<div class="Ih2E3d"><br>
Hope this helps.<br>
<br>
Regards, Dan<br>
<br>
</div>2008/10/22 Stéphane CALANDE <<a href="mailto:scalande@gmail.com">scalande@gmail.com</a>>:<br>
<div><div></div><div class="Wj3C7c">> Finally, I think that "itkAddImageFilter" is not what I need.<br>
><br>
> Which function can I use to create a program that takes multiple 3D<br>
> images.mhd as input and create as output one 3D image.mhd containing the<br>
> average(mean) of the multiple images ?<br>
><br>
> Any help is appreciated...<br>
><br>
><br>
> Thank you !<br>
><br>
><br>
><br>
> Stéphane<br>
><br>
><br>
><br>
><br>
> 2008/10/22 Stéphane CALANDE <<a href="mailto:scalande@gmail.com">scalande@gmail.com</a>><br>
>><br>
>> Hi Luis, hi everybody...<br>
>><br>
>><br>
>> I have little problems with the program I created to add my images (see<br>
>> former mail) : in fact I badly expressed myself.<br>
>> I don't want a program that "sums" my 3D metaheaders images, but I want a<br>
>> program that give, as output, a file containing a MEAN of the images.<br>
>><br>
>> If I have 10 images represented by different "grey-level", the image I<br>
>> want is an other "grey-level" one (but now the problem is that the output<br>
>> image is black and white, probably because of the SUM, isn't it?)<br>
>><br>
>><br>
>> Luis, I'd like to know if the program you gave me (just under this mail)<br>
>> can resolve that problem ?<br>
>><br>
>> I'm trying to compile it but the variable "adder" is undeclared... What is<br>
>> the type of "adder" ? Can you help me ?<br>
>><br>
>><br>
>> Thank you very much !!<br>
>><br>
>><br>
>><br>
>> Stéphane<br>
>><br>
>><br>
>> 2008/10/16 Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>><br>
>>><br>
>>> Hi Stéphane<br>
>>><br>
>>> It should be relatively straight forward to implement this.<br>
>>><br>
>>> Put the list of filenames in an array of std::strings called<br>
>>> "name" and do the following:<br>
>>><br>
>>><br>
>>> reader->SetFileName( name[0] );<br>
>>> reader->Update();<br>
>>> ImageType::Pointer inputImage1 = reader->GetOutput();<br>
>>> adder->SetInput1( inputImage1 );<br>
>>><br>
>>> for( int i=0; i<numberOfFiles; i++)<br>
>>> {<br>
>>> reader->SetFileName( name[i] );<br>
>>> reader->Update();<br>
>>> ImageType::Pointer inputImage2 = reader->GetOutput();<br>
>>> inputImage2->DisconnectPipeline();<br>
>>> adder->SetInput2( inputImage2 );<br>
>>> adder->Update();<br>
>>> ImageType::Pointer sumImage = adder->GetOutput();<br>
>>> sumImage->DisconnectPipeline();<br>
>>> adder->SetInput1( sumImage );<br>
>>> }<br>
>>><br>
>>> // Here sumImage has the output.<br>
>>><br>
>>><br>
>>> Note the use of the DisconnectPipeline() method, that<br>
>>> makes possible to reuse the reader and the adder filter.<br>
>>><br>
>>><br>
>>><br>
>>> Regards,<br>
>>><br>
>>><br>
>>> Luis<br>
>>><br>
>>><br>
>>> -------------------------<br>
>>> Stéphane CALANDE wrote:<br>
>>>><br>
>>>> Hi,<br>
>>>><br>
>>>><br>
>>>> I'm a newbie in ITK and I'm looking for a example of program that takes,<br>
>>>> as input, several 3D metaheader image (.mhd) having the same spacing,<br>
>>>> size,... and that "sums" these images to create one "total_Image.mhd" having<br>
>>>> the same size, spacing,... than the input ones.<br>
>>>><br>
>>>><br>
>>>> Does it exist ?<br>
>>>><br>
>>>><br>
>>>> Thank you very much.<br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> Regards,<br>
>>>><br>
>>>><br>
>>>> Stéphane<br>
>>>><br>
>>>><br>
>>>> ------------------------------------------------------------------------<br>
>>>><br>
>>>> _______________________________________________<br>
>>>> Insight-users mailing list<br>
>>>> <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>
>>>> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
>><br>
><br>
><br>
> _______________________________________________<br>
> Insight-users mailing list<br>
> <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</div></div></blockquote></div><br>