[Insight-developers] Compile-time decorator pattern

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Sun Jan 9 02:18:21 EST 2011


Hi Brad,

It looks interesting.

Have you chosen the tophat filter on purpose?
Is it because it is a minipeline filter?

For the specific case of in place filtering, I was thinking about the  
idea of implementing that feature directly in ImageToImageFilter. It  
may be another way to fix your problem.

Regards,

Gaëtan


Le 7 janv. 11 à 19:42, Bradley Lowekamp a écrit :

> Hello,
>
> I have just push a little branch which shows the basis for a  
> potentially very useful design pattern for ITK filters:
>
> http://review.source.kitware.com/#change,684
>
> I could not find an official name for this patterns, I have read  
> about it before and used it in a few places as well in other  
> projects. I decided to call it "compile-time decorator" because it's  
> design to add features to a multiple class hierarchies.
>
> The motivation is to be able add reuse functionality, without  
> changing exiting hierarchy structures. This an alternative to  
> multiple inheritance in for some situations.
>
>
> The implementation of the pattern is to have the parent of a class  
> be a template argument to the class.
>
> template< class TInputImage, class TOutputImage = TInputImage,
>                    class TParentImageFilter = ImageToImageFilter<  
> TInputImage, TOutputImage > > class ITK_EXPORT  
> InPlaceImageFilter:    public TParentImageFilter {...}
>
> For example say I have a good inplace algorithm for  
> WhiteTopHatImageFilter:
> http://www.itk.org/Doxygen/html/ 
> classitk_1_1WhiteTopHatImageFilter.html
>
> However, it's already embedded in an existing complex hierarchy, so  
> I can not re-organize the class to be derived from InPlaceFilter.  
> However, it's is good practice to reuse the existing code in the  
> InPlace filter. This can be over come with this pattern by declaring  
> the class in the following fashion.
> 			
> template< class TInputImage, class TOuputImage, class TKernel >
> class ITK_EXPORT WhiteTopHatImageFilter:
> 	public InPlaceImageFilter<TInputImageFilter, TOutputImageFilter,  
> KernelImageFilter< TInputImage, TOutputImage, TKernel > >
> {...}
>
>
> This may be a useful design pattern for GPU implementations of  
> filters, along with adding certain streaming functionality to sinc  
> like filters.
>
> Brad
>
> ========================================================
> Bradley Lowekamp
> Lockheed Martin Contractor for
> Office of High Performance Computing and Communications
> National Library of Medicine
> blowekamp at mail.nih.gov
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers

-- 
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  http://www.itk.org
http://www.mandriva.org  http://www.bepo.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 203 bytes
Desc: Ceci est une signature ?lectronique PGP
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20110109/add03ef9/attachment.pgp>


More information about the Insight-developers mailing list