[Insight-users] ITK example that sums multiple metaheader images
Dan Mueller
dan.muel at gmail.com
Wed Oct 22 08:46:34 EDT 2008
Hi Stéphane,
> - Why do you tell me about "NaryAddImageFilter" ? I was using
> AddImageFilter.
I mentioned NaryAddImageFilter in my first response to your question
(which I see now I forgot to send to the mailing list).
> What's the difference ?
AddImageFilter takes 2 inputs, NaryAddImageFilter takes N inputs (ie.
unary, binary, "n"-ary).
> - I have no "NaryAddImageFilter.cxx" or "AddImageFilter.cxx" in my ITK
> repertory. I didn't find it on the Internet either. Where can I find it if I
> want to transform "Add" to "Mean" ?
You will find it in Code\BasicFilters\itkNaryAddImageFilter.h.
Hope this helps.
Regards, Dan
2008/10/22 Stéphane CALANDE <scalande at gmail.com>:
> Thank you Dan ;-)
>
> I have 2 questions :
>
> - Why do you tell me about "NaryAddImageFilter" ? I was using
> AddImageFilter. What's the difference ?
>
> - I have no "NaryAddImageFilter.cxx" or "AddImageFilter.cxx" in my ITK
> repertory. I didn't find it on the Internet either. Where can I find it if I
> want to transform "Add" to "Mean" ?
>
>
>
> Have a nice day,
>
>
>
> Stéphane
>
>
>
> 2008/10/22 Dan Mueller <dan.muel at gmail.com>
>>
>> Hi Stéphane,
>>
>> Yes, good point: the MeanImageFilter will not work for multiple
>> images. Sorry for the confusion, I did not think carefully enough
>> before sending the email.
>>
>> You will either have to make your own NaryMeanImageFilter (similar to
>> NaryAddImageFilter) or use the NaryAddImageFilter and the
>> DivideImageFilter together.
>>
>> Regards, Dan
>>
>> 2008/10/22 Stéphane CALANDE <scalande at gmail.com>:
>> > Thank you very much for your help Dan,
>> >
>> >
>> > I tried "MeanImageFilter" but I'm not sure I can calculate the mean of
>> > several images.
>> > In fact, the functions SetInput1, SetInput2,... don't exist for
>> > MeanImageFilter...
>> >
>> > Do you have some advice ?
>> >
>> >
>> > Meanwhile, I'm going to try the DivideImageFilter.
>> >
>> >
>> >
>> > Thank you in advance,
>> >
>> >
>> >
>> > Stéphane
>> >
>> >
>> >
>> >
>> > 2008/10/22 Dan Mueller <dan.muel at gmail.com>
>> >>
>> >> 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