[Insight-developers] How simple is SimpleITK
Gaëtan Lehmann
gaetan.lehmann at jouy.inra.fr
Tue Jan 25 14:29:48 EST 2011
Dan,
During the last SimpleITK tcon, I think we've talked about trying to
generate a set of functions to make the coding style more procedural.
IIRC, they would
* hide the filter creation and use of Set and Execute methods
* be in an sitk name space
* remove the Filter suffix
That would give something very close to what Bill would like:
sitk::Image::Pointer image = sitk::readImage(inputfilename);
image = sitk::recursiveGaussian(image, sigma);
sitk::writeImage(outputfilename);
In c++, there is still the Pointer though, but not in python:
import sitk
image = sitk.readImage(inputfilename)
image = sitk.recursiveGaussian(image, sigma)
sitk.writeImage(outputfilename)
this kind of syntax is OK for a python developer, really.
There is a lot of code in python libs in procedural style and even
some functional style.
Gaëtan
Le 25 janv. 11 à 19:03, Bill Lorensen a écrit :
> 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
>>
> _______________________________________________
> 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/20110125/2b59099e/attachment.pgp>
More information about the Insight-developers
mailing list