[Insight-users] Java wrappers import/export data
Alejandro Canales Ochoa
aco at cion.com.mx
Thu, 4 Mar 2004 04:01:20 -0600
Bill, thanks for your attention.
>I would like to get the API figured out first. Basically, it sounds
>like you want to go from Java images to itk images, and from itk images
>to java images.
Does not sound GREAT? That’s exactly what I want. Excuse me if I was not been clear in past emails.
IMPORTING AN IMAGE
If I understand you, the ImportFilter should not be a problem for you to implement. I see the SwingExtras.java and understand that it provides you with a proxy class to create/remove arrays of primitive types. The only thing I was concern is that it needs to make a JNI call for each member of the array you need to set/get, and the performance could be affected. Maybe a two step approach should be used, one for allocate the C-Native array and the other to set/get a range in the array, thus reducing the JNI calls to two. Another concern is that there is missing a support for unsigned short in SwingExtras.java, but I suppose that should not be difficult to accomplish this since it’s a wrapper for C code.
EXPORTING AN IMAGE
I was looking at the itkImageBase2 code, and after I read something about cswig (thanks for the link) I wonder if it is possible to instantiate in java an object representing the image type from the pointer returned by the GetOutput method of the filters. As I understand, the SWIGTYPE_p_itk__ImageTx_y_z is a wrapper for an image pointer, so I think I can pass this pointer to the constructor of an itkImage, something like this:
SWIGTYPE_p_itk__ImageTunsigned_char_2_t readerOut = reader.GetOutput();
itkImageUC2_Pointer image = new itkImageUC2_Pointer(SWIGTYPE_p_itk__ImageTunsigned_char_2_t.getCPtr(readerOut), false);
If the code above does not work, then HOW CAN I ACCESS PIXEL DATA FROM JAVA AT THIS MOMENT?
For the export API, I think that the adapter (I don’t know if the term adapter is used correctly here) should expose the image as an array of the type it was made of, along with the image info like size, spacing, origin, etc. Once I have the data buffer and the image info, it’s a trivial task to create a PlanarImage.
Thanks in advance and please let me know if I was unclear in what I need.
Alejandro Canales