[Insight-users] Why are getBufferAs* methods not available in Java?

Bradley Lowekamp blowekamp at mail.nih.gov
Wed Mar 13 15:51:38 EDT 2013


Hello,

Glad to hear you are using SimpleITK in Java.

On Mar 13, 2013, at 3:02 PM, Mathew Guilfoyle <mrguilfoyle at gmail.com> wrote:

> Hi, I am trying to use the Java SimpleITK wrapper for medical image processing.  
> 
> I need to do some manipulation of the image as a plain numerical array before and after leveraging the ITK segmentation filters.  However, I can't find an efficient way of either transferring a numerical array to an SITK Image object or reverting an Image object back to a numerical array.  Using nested loops to do a per-pixel setPixelAs* or getPixelAs* operation takes an inordinate amount of time.   

Yes, these are "safe" methods that are not designed to operate on the entire image in that way. Even the similar methods in ITK are quire slow.

> 
> I understand the getPixelContainer method is now deprecated (?) and was supposed to be replaced by the getBufferAs* methods, which I can see in the Doxygen Image class listing but seem to be suppressed in the Java wrapper (v0.6.1).  Is there a way round this?

The PixelContainer structure was an aborted early attempt at providing this raw access. Since then we settled on this getBufferAs method, and it's work very well for C++, and C#. While for Python we implemented separate function for a numpy interface. With the right knowledge of Java, and SWIG it should not be too hard to get this part of the interface working in Java. If you are willing to tackle this I'll help you along.

Here would be the place to get started with change how SWIG treats these methods:
https://github.com/SimpleITK/SimpleITK/blob/master/Wrapping/SimpleITK.i#L61

and in SWIG there are a variety of ways to wrap these raw arrays:
http://www.swig.org/Doc2.0/Java.html#Java_c_arrays
http://www.swig.org/Doc2.0/Java.html#Java_unbounded_c_arrays

Java has not been a heavily download from SourceForge, so this has not been a high priority issue.

Brad

> 
> Many thanks for any help/advice
> 
> Mathew
> _____________________________________
> 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://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list