[ITK-users] Iterator for python supported ITK

Lowekamp, Bradley (NIH/NLM/LHC) [C] blowekamp at mail.nih.gov
Mon May 23 08:46:43 EDT 2016


Hello,

This is an intrinsic problem with using an interpretive language to perform per-element operations with many elements. Fundamentally these type of operation in C++ involve just a few CPU instructions, while in native python it will involve 100X more with string compares and symbol table look ups. There is the same problem if you tries to index your way through a numpy array.  In numpy there are many optimization frameworks such a cython and numba implemented to optimize and “compile” these types of operations.

But sometimes if your image is small and performance doesn’t matter the ITK iterators would be OK. You could look into wrapping them following the instructions in the ITK Software guide.

Brad

> On May 22, 2016, at 8:20 PM, 沈庄明 <zhuangming.shen at sphic.org.cn> wrote:
> 
> Hi Matt,
> 
> Thanks for your prompt reply. Actually, I'd like to know how to further improve the performance when I need to get each pixel value from an image using python supported ITK. 
> 
> 
> Regards,
> 
> Zhuangming Shen
> ________________________________________
> From: Matt McCormick <matt.mccormick at kitware.com>
> Sent: Friday, May 20, 2016 8:00 PM
> To: 沈庄明
> Cc: insight-users at itk.org
> Subject: Re: [ITK-users] Iterator for python supported ITK
> 
> Hi Zhuangming,
> 
> Iterating through pixels is slow in Python -- the iterators may not be
> wrapped because it is always a good idea to use C++ in this case.
> 
> HTH,
> Matt
> 
> On Fri, May 20, 2016 at 5:00 AM, 沈庄明 <zhuangming.shen at sphic.org.cn> wrote:
>> Hi all,
>> 
>> 
>> Could anyone give me an example on "itk::ImageRegionIterator" using Python
>> supported ITK? I can't find the wrapped "iterator". Thanks in advance.
>> 
>> 
>> 
>> Regards,
>> 
>> 
>> Zhuangming Shen
>> 
>> 
>> _____________________________________
>> 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://www.kitware.com/products/protraining.php
>> 
>> 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://public.kitware.com/mailman/listinfo/insight-users
>> 
> _____________________________________
> 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://www.kitware.com/products/protraining.php
> 
> 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://public.kitware.com/mailman/listinfo/insight-users



More information about the Insight-users mailing list