[Insight-developers] How simple is SimpleITK
Bill Lorensen
bill.lorensen at gmail.com
Tue Jan 25 13:03:18 EST 2011
Dan,
My example was extreme and meant to be provocative.
I like your first approach (without the Pointer)
using namespace itk::simple;
Image image;
image = ImageFileReader ( "Foo" );
image = RecursiveGaussian ( image, 2.0 )
ImageFileWriter ( image, "Bar" );
or even
itk::simple::Image image;
image = itk::simple::ImageFileReader ( "Foo" );
image = itk::simple::RecursiveGaussian ( image, 2.0 )
itk::simple::ImageFileWriter ( image, "Bar" );
I think the OO pattern is not as simple. Who is the audience, Python
and Java developers or biomedical researchers?
Sorry I was not in Iowa and won't be in Boston. I hope you have a
lively and procutive meeting.
Bill
On Tue, Jan 25, 2011 at 12:50 PM, Blezek, Daniel J.
<Blezek.Daniel at mayo.edu> wrote:
> Hi Bill,
>
> For some reason everyone thinks that SimpleITK is going to look like
> Matlab... The plan has been to _enable_ Matlab-like syntax, not demand
> it. We will continue the object oriented pattern, but augment with a
> set of procedural calls. So your example code would end up looking
> something like this:
>
>
> using namespace itk::simple;
> Image::Pointer image;
> image = ImageFileReader ( "Foo" );
> image = RecursiveGaussian ( image, 2.0 )
> ImageFileWriter ( image, "Bar" );
>
> Or, if you like, this can be all done on one line...
>
> ImageFileWriter ( RecursiveGaussian ( ImageFileReader ( "Foo" ), 2.0 ),
> "Bar" );
>
> In the OO pattern:
>
> image = ImageFileReader().SetFilename ( "Foo" ).Execute()
> image = RecursiveGaussion().SetSigma ( 2.0 ).Execute ( image )
> ImageFileWriter().SetFilename ( "Bar" ).Execute ( image )
>
> We are investigating making Execute a static method, so the code would
> look like:
>
> image = ImageFileReader::Execute ( "Foo" )
> image = RecursiveGaussian::Execute ( image, 2.0 )
> ImageFileWriter::Execute ( image, "Bar" )
>
> This has not been checked in, because SWIG does not wrap it properly. I
> am working on this.
>
> At the Iowa meeting, we decided to take the OO approach, as it was more
> broadly approachable to Python and Java developers.
>
> -dan
>
> -----Original Message-----
> From: insight-developers-bounces at itk.org
> [mailto:insight-developers-bounces at itk.org] On Behalf Of Bill Lorensen
> Sent: Tuesday, January 25, 2011 11:28 AM
> To: Insight Developers
> Subject: [Insight-developers] How simple is SimpleITK
>
> Folks,
>
> I just took a look at the current SimpleITK repo.
>
> To me it looks like itk without templates and without pipelines.
> Simpler indeed. And probably simpler to wrap.
>
> However, it still is object-oriented, has namespaces, has Pointer's,
> still uses set/get methods and still has an Execute method. It is still
> quite ITK-like.
>
> I thought it would be a bit more procedural and more acceptable to
> non-itk(e.g. Matlab) users.
>
> itksImage image = itksReadImage(inputfilename);
> image=itksRecursiveGaussian(image, sigma);
> itksWriteImage(outputfilename);
>
> versus
>
> itk::simple::Image::Pointer image;
> itk::simple::ImageFileReader reader;
> reader.SetFileName ( inputFilename);
> image = reader.Execute();
>
> itk::simple::RecursiveGaussianImageFilter gaussian;
> gaussian.SetSigma ( gaussian );
> image = gaussian.Execute ( image );
>
> itk::simple::ImageFileWriter writer;
> writer.SetFileName ( outputFilename );
> writer.Execute ( image );
>
> Bill
> _______________________________________________
> 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
>
More information about the Insight-developers
mailing list