[Insight-users] ITK example that sums multiple metaheader images
Dan Mueller
dan.muel at gmail.com
Wed Oct 22 06:36:47 EDT 2008
Hi Stéphane,
You probably want the MeanImageFilter:
http://www.itk.org/Doxygen/html/classitk_1_1MeanImageFilter.html
You can use it in the same way as the add image filter that Luis
described in his reply to your original question.
reader->SetFileName( name[0] );
reader->Update();
ImageType::Pointer inputImage1 = reader->GetOutput();
mean->SetInput1( inputImage1 );
for( int i=1; i<numberOfFiles; i++)
{
reader->SetFileName( name[i] );
reader->Update();
ImageType::Pointer inputImage2 = reader->GetOutput();
inputImage2->DisconnectPipeline();
mean>SetInput2( inputImage2 );
mean->Update();
ImageType::Pointer sumImage = adder->GetOutput();
meanImage->DisconnectPipeline();
mean->SetInput1( meanImage );
}
// Here meanImage has the output.
Alternatively, you could use the DivideImageFilter after you have
computed the sum:
http://www.itk.org/Doxygen/html/classitk_1_1DivideImageFilter.html
Hope this helps.
Regards, Dan
2008/10/22 Stéphane CALANDE <scalande at gmail.com>:
> Finally, I think that "itkAddImageFilter" is not what I need.
>
> Which function can I use to create a program that takes multiple 3D
> images.mhd as input and create as output one 3D image.mhd containing the
> average(mean) of the multiple images ?
>
> Any help is appreciated...
>
>
> Thank you !
>
>
>
> Stéphane
>
>
>
>
> 2008/10/22 Stéphane CALANDE <scalande at gmail.com>
>>
>> Hi Luis, hi everybody...
>>
>>
>> I have little problems with the program I created to add my images (see
>> former mail) : in fact I badly expressed myself.
>> I don't want a program that "sums" my 3D metaheaders images, but I want a
>> program that give, as output, a file containing a MEAN of the images.
>>
>> If I have 10 images represented by different "grey-level", the image I
>> want is an other "grey-level" one (but now the problem is that the output
>> image is black and white, probably because of the SUM, isn't it?)
>>
>>
>> Luis, I'd like to know if the program you gave me (just under this mail)
>> can resolve that problem ?
>>
>> I'm trying to compile it but the variable "adder" is undeclared... What is
>> the type of "adder" ? Can you help me ?
>>
>>
>> Thank you very much !!
>>
>>
>>
>> Stéphane
>>
>>
>> 2008/10/16 Luis Ibanez <luis.ibanez at kitware.com>
>>>
>>> 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
>>
>
>
> _______________________________________________
> 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