[Insight-developers] FFTW filters new New() method

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Sat Nov 25 12:08:30 EST 2006


Nobody seems to be against, so I'm committing the changes

Gaetan


Le Thu, 02 Nov 2006 16:14:06 +0100, Gaetan Lehmann  
<gaetan.lehmann at jouy.inra.fr> a écrit:

>
> Hi,
>
> After some minor changes, the code posted by Jakub works without  
> problem. All the FFT filter related tests are green, and the new New()  
> method works just nice.
> If nobody is against, I'll commit the changes in the cvs when ITK 3.0  
> will be released.
>
> Regards,
>
> Gaetan
>
>
>
> On Sun, 29 Oct 2006 19:11:25 +0100, Jakub Bican <jakub.bican at matfyz.cz>  
> wrote:
>
>>
>> Hi,
>>
>> i implemented Gaetan's idea and attached the modified files. I am
>> testing it in some of my projects and it works nice;)
>>
>> Please, if you find it useful, consider putting it to ITK. If it is
>> necessary, i can post it in IJ, but i won't do that for these 30 lines
>> implicitly :)))
>>
>> Thanks,
>>
>>        Jakub
>>
>>
>> Jakub Bican napsal(a):
>>> Thanks Luis,
>>>
>>> i studied this already, but it does not explain everything i need.
>>> Moreover, implementing factory for templated class requires some extra
>>> effort.
>>>
>>> Can you consider the solution suggested by Gaetan, please? It seems
>>> really practical, while it does not affect existing code based on FFT
>>> in any way.
>>>
>>> Regards,
>>>
>>>         Jakub
>>>
>>>
>>> 2006/10/26, Luis Ibanez <luis.ibanez at kitware.com
>>> <mailto:luis.ibanez at kitware.com>>:
>>>
>>>
>>>
>>>     Hi Jakub,
>>>
>>>
>>>     If you are interested in overriding a factory with another one,
>>>     you may want to look at the following course material:
>>>
>>>
>>>     http://www.na-mic.org/Wiki/index.php/Dissemination:EPFL_Workshop_2005
>>>
>>>
>>>     In particular to the presentation:
>>>
>>>     http://www.na-mic.org/Wiki/images/2/24/Insight-DesignPatterns.ppt
>>>     <http://www.na-mic.org/Wiki/images/2/24/Insight-DesignPatterns.ppt>
>>>
>>>
>>>     The discussion on Factories starts on slide 53.
>>>
>>>     The source code of examples for Factories can be found at
>>>
>>>     http://www.na-mic.org:8000/svn/NAMICSandBox/trunk/ITKAdvancedCourse/
>>>     <http://www.na-mic.org:8000/svn/NAMICSandBox/trunk/ITKAdvancedCourse/>
>>>
>>>
>>>     In Exercise 29:
>>>     http://www.na-mic.org:8000/svn/NAMICSandBox/trunk/ITKAdvancedCourse/src/Exercises/exercise29/
>>>     <http://www.na-mic.org:8000/svn/NAMICSandBox/trunk/ITKAdvancedCourse/src/Exercises/exercise29/>
>>>
>>>
>>>         Regards,
>>>
>>>
>>>            Luis
>>>
>>>
>>>     =---------------------------
>>>     Jakub Bican wrote:
>>>     >
>>>     > Hi Gaetan,
>>>     >
>>>     > as i more and more understand the problem of factories, it is
>>>     clear to
>>>     > me, that this is the most elegant solution.
>>>     >
>>>     > Your suggestion have to be complicated only a little bit more by
>>>     > determining, if the actual PixelType matches the type of FFTW
>>>     library
>>>     > linked: i.e. use FFTW only if FFTWF is defined and PixelType is
>>>     float or
>>>     > FFTWD is defined and pixeltype is double.
>>>     >
>>>     > There should be also check if there is some factory for the
>>>     class, as it
>>>     > is in itkNewMacro (in case someone will use dynamic library with
>>>     new FFT
>>>     > implementation)
>>>     >
>>>     > Is it possible to make such change to ITK cvs version?
>>>     >
>>>     > I hope this will help to many people that are writing filters
>>>     using FFT.
>>>     >
>>>     > Thanks,
>>>     >
>>>     >       Jakub
>>>     >
>>>     >
>>>     >
>>>     >
>>>     > Gaetan Lehmann napsal(a):
>>>     >
>>>     >>
>>>     >> Hi Jakub,
>>>     >>
>>>     >> That's only my point of view, but don't you think that the
>>>     factory is
>>>     >> quite complicated for that case ?
>>>     >> IMHO opinion, a customized New() method in
>>>     >> RealToComplexConjugateImageFilter would do the job without  
>>> problem.
>>>     >> Something like:
>>>     >>
>>>     >> static Pointer New()
>>>     >>   {
>>>     >> #if defined(USE_FFTWF)
>>>     >>   return FFTWRealToComplexConjugateImageFilter<PixelType,
>>>     >> ImageDimension>::New().GetPointer();
>>>     >> #else
>>>     >>   return VnlFFTRealToComplexConjugateImageFilter<PixelType,
>>>     >> ImageDimension>::New().GetPointer();
>>>     >> #endif
>>>     >>   }
>>>     >>
>>>     >> Regards,
>>>     >>
>>>     >> Gaetan
>>>     >>
>>>     >>
>>>     >>
>>>     >> On Thu, 26 Oct 2006 11:51:13 +0200, Jakub Bican
>>>     >> <jakub.bican at matfyz.cz <mailto:jakub.bican at matfyz.cz>> wrote:
>>>     >>
>>>     >>>
>>>     >>> Hi,
>>>     >>>
>>>     >>> things seem more clear now: I have to make just one class
>>>     >>> (FFTFactory:ObjectFactoryBase) that calls RegisterOverride()
>>>     in its
>>>     >>> constructor to override creation of
>>>     RealToComplexConjugateImageFilter
>>>     >>> and ComplexConjugateToRealImageFilter by available  
>>> implementation
>>>     >>> from VNL or FFTW.
>>>     >>>
>>>     >>> But the questions remains the same:
>>>     >>> 1) how to register this factory as "implicit default factory" -
>>>     >>> without need to register it manually in every filter or every
>>>     program
>>>     >>> that uses FFT
>>>     >>>
>>>     >>> 2) what happens if there will be new FFT implementation in  
>>> dynamic
>>>     >>> library, that will override in the same way - which factory
>>>     will have
>>>     >>> priority? (if the dynamic one overrides the default one, then
>>>     it is
>>>     >>> ok - that is the intention, but does it really happen?)
>>>     >>>
>>>     >>>
>>>     >>> Regards,
>>>     >>>
>>>     >>>         Jakub
>>>     >>>
>>>     >>>
>>>     >>>
>>>     >>>
>>>     >>> -------- Původní zpráva --------
>>>     >>>
>>>     >>> Hello,
>>>     >>>
>>>     >>> i would like to implement a factory mechanism for FFT filters.  
>>> The
>>>     >>> point is that if the user selects "USE_FFTW" once during
>>>     >>> configuration, then the factory mechanism will provide him
>>>     FFTW-based
>>>     >>> classes instead of standard VNL implementation. And user can  
>>> also
>>>     >>> create his own dll with some fft implementation and attach it
>>>     >>> dynamically to his project.
>>>     >>>
>>>     >>> I studied the tutorial
>>>     >>>
>>>     (http://www.na-mic.org/Wiki/images/2/24/Insight-DesignPatterns.ppt
>>>     <http://www.na-mic.org/Wiki/images/2/24/Insight-DesignPatterns.ppt>)
>>>     >>> including examples.
>>>     >>>
>>>     >>> I would like to ask someone if i understand well what i have
>>>     to do:
>>>     >>>
>>>     >>> step A) create factories FFTWFFTFactory and VNLFFTFactory
>>>     (derived
>>>     >>> from following class), that will override creation of
>>>     >>> RealToComplexConjugateImageFilter and
>>>     >>> ComplexConjugateToRealImageFilter types so that an instance  
>>> from
>>>     >>> appropriate implementation is created.
>>>     >>>
>>>     >>> step B) create class FFTFactoryBase (derived from
>>>     ObjectFactoryBase)
>>>     >>> that will be implemented similary to TransformFactoryBase and  
>>> that
>>>     >>> will register one of the above factories, depending on if the
>>>     FFTW is
>>>     >>> used or not
>>>     >>> (this is difference to TransformFactoryBase, which registers  
>>> all
>>>     >>> known factories, while the new class will register only one
>>>     depending
>>>     >>> on configuration)
>>>     >>>
>>>     >>>
>>>     >>> And i have some questions:
>>>     >>>
>>>     >>> 1) what is the correct way of registering FFTFactoryBase
>>>     >>> automatically, so that it registers appropriate factory "at the
>>>     >>> beginning"?
>>>     >>> I don't want to register it explicitly at the beginning of  
>>> every
>>>     >>> program that will use FFT - i just want to call
>>>     >>> RealToComplexConjugateImageFilter::New() and get FFTW
>>>     implementation
>>>     >>> if i attached FFTW library to ITK or VNL implementation  
>>> otherwise.
>>>     >>>
>>>     >>> 2) what happens if someone loads dll into ITK_AUTOLOAD_PATH  
>>> with a
>>>     >>> new FFT implementation and corresponding factory? What will be
>>>     >>> overriden by what?
>>>     >>>
>>>     >>> Thanks in advance for guidance and answers,
>>>     >>>
>>>     >>>    Jakub
>>>     >>>
>>>     >>>
>>>     >>>
>>>     >>>
>>>     >>>
>>>     >>> _______________________________________________
>>>     >>> Insight-users mailing list
>>>     >>> Insight-users at itk.org <mailto:Insight-users at itk.org>
>>>     >>> http://www.itk.org/mailman/listinfo/insight-users
>>>     >>
>>>     >>
>>>     >>
>>>     >>
>>>     >> --Gaëtan Lehmann
>>>     >> Biologie du Développement et de la Reproduction
>>>     >> INRA de Jouy-en-Josas (France)
>>>     >> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
>>>     >> http://voxel.jouy.inra.fr
>>>     >>
>>>     >>
>>>     > _______________________________________________
>>>     > Insight-users mailing list
>>>     > Insight-users at itk.org <mailto:Insight-users at itk.org>
>>>     > http://www.itk.org/mailman/listinfo/insight-users
>>>     >
>>>
>>>
>
>
>



-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr


More information about the Insight-developers mailing list