[Insight-developers] Strategy pattern for SimpleITK
Gaëtan Lehmann
gaetan.lehmann at jouy.inra.fr
Sat Nov 6 20:14:52 EDT 2010
Le 6 nov. 10 à 12:24, Dan Mueller a écrit :
> Hi all,
>
> I cannot attend the ITKv4 meeting in Iowa.
>
> Before the meeting I wanted to put together an example of how the
> strategy pattern
> http://en.wikipedia.org/wiki/Strategy_pattern
> could be used to simplify ITK.
>
> Unfortunately I have not had time to put the finishing touches on the
> example, but I include it here nonetheless. I hope it can be
> discussed.
> https://github.com/danmuel/SimpleITK/commit/275570295619aa3c812bcf3c7973eff84c374bc7
>
> In my example, I created "itkSimpleUnaryImageFilter" which employs the
> "itkStrategyFactory" to bring together 20+ filters into a single
> filter. If I had the time, it would have been used as follows (using
> C# wrapping):
> Unary unary = new Unary();
> unary.setStrategy(UnaryStrategy.UnaryStrategyAbs);
> //unary.setStrategy(UnaryStrategy.UnaryStrategyExp); // Cos,
> Log10, Log, Not, Sin, Tan...
> image = unary.execute(image);
>
> The strategy pattern could be applied to a wide range of
> filters/object, including the registration framework Eg. (syntax
> dreamed up)
> Metric metric = new Metric(MetricStrategy.NormalizedCorrelation);
> metric.setSomeParameter(someValue1);
> Interpolator interpolator = new
> Interpolator(InterpolatorStrategy.BSpline);
> Transform transform = new Transform(TransformStrategy.Affine);
> Optimizer optimizer = new
> Optimizer(OptimizerStrategy.GradientDescent);
> optimizer.setSomeParameter(someValue2);
> RegistrationMethod registration = new RegistrationMethod();
> registration.setMetric(metric);
> registration.setInterpolator(interpolator);
> registration.setTransform(transform);
> registration.setOptimizer(optimizer);
> registration.setFixedImage(fixed);
> registration.setMovingImage(moving);
> registration.execute();
>
> Here is an initial list of possible objects which could employ the
> pattern:
> UnaryPixelMath: Abs, Acos, Asin, Atan, Cos, Exp, Log10, Log, Not,
> Sigmoid, Sin, Sqrt, Square, ...
> BinaryPixelMath: Add, Subtract, Multiple, Divide, And, Or, Xor,
> Maximum, Minimum, Mask, SquaredDifferance, CheckerBoard, ...
> InterpolateImageFunction: Linear, BSpline, CosineWindowedSinc,
> HammingWindowedSinc, LanczosWindowedSinc, WelchWindowedSinc
> DistanceMap: Danielsson, SignedDanielsson, Chamfer, ApproximateSigned,
> SignedMaurer
> Morphology: BinaryDilate, BinaryErode, BinaryOpen, BinaryClose,
> BinaryShapeOpen, GreyscaleOpen, GreyscaleClose, GreyscaleDilate,
> GreyscaleErode, AreaOpen, AnchorOpen, AnchorClose,
> VanHerkGilWermanOpen, VanHerkGilWermanClose, ...
> ImageToImageMetric: KappaStatistic, MatchCardinality,
> MattesMutualInformation, MeanReciprocalSquareDifference, MeanSquares,
> NormalizedCorrelation, NormalizedMutualInformationHistogram
>
> Obviously there are still some issues to sort out, but I think the
> strategy pattern can really help make ITK "simple".
>
> What do you think?
Hi Dan,
I think it looks interesting even outside of the simple itk project:
this kind of strategy can be use to group the filters in ITK itself,
and would be useful in many cases.
It can then be reused to implement simple ITK.
Regards,
Gaëtan
--
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/20101107/3a3aa88e/attachment.pgp>
More information about the Insight-developers
mailing list