SimpleITK - connecting to other image processing libraries

Hey all,
@blowekamp @matt.mccormick

first of all congrats to the developers for the SimpleITK 2.0 release! :partying_face:

I was just exploring it from Java and I’m wondering how to pipe pixels from another source into an ITK image. I do have various options for accessing pixels from our side but I can’t see a way for creating an ITK Image from them.

In my typical workflows, images exist as JNI Buffer, that’s an array allocated in a native C++ library, and Java has only a pointer to it. I could copy over that array in a Java float[] array (which appears a de-tour). Furthermore, I could offer the image encapsulated in various ImageJ objects. But that boils down to arrays of arrays of type float for example.

Is there a code example showing how to create a Simple ITK image from a Java float[] array or a JNI pointer and given dimensions? The opposite direction would be interesting as well. btw. :slight_smile:

Thanks in advance!

Cheers,
Robert

1 Like

Hello @haesleinhuepf,

To create a SimpleITK image from a buffer, use the ImportImageFilter, don’t forget to set the origin/spacing/direction cosine.

To get the image buffer back use the Image’s GetBufferAsXYZ methods.

3 Likes

Hey @zivy,

thanks for the hints! Unfortunately, the Java API doesn’t expose these methods:
image

image

Are you sure they are part of SimpleITK 2.0.0?

In case that’s helpful, my full code lives here.

Thanks!

Cheers,
Robert

1 Like

You are correct. The ImportImageFilter is not available for the Java interface ( nor any other wrapped language ) due to expose of raw buffer pointers.

The CSharpIntegration example may be of some use to figure out how to copy the buffer in Java.

Contributions to improve the documentation and efficiency of the interface is certainly welcome :slight_smile:

2 Likes

Please create feature request as a Github Issue so that we can determine what needs to be done to fix and improve the interface to enable this.

2 Likes

Alright, I did so.

Thanks for taking a look into this and let me know if I can help!

2 Likes