[Insight-users] Java wrappers import/export data

William A. Hoffman billlist at nycap.rr.com
Mon, 08 Mar 2004 14:06:03 -0500


>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);
This was a bug in CableSwig, I have checked in a fix.  The GetOuput now returns
a itkImageUC2 and not a SWIGTYPE_p class.   The SWIGTYPE_p classes is how non-wrapped
class pointers are handled by swig.   They are not useful for much other than being
able to pass them around.  In this case the image was being wrapped, but there
was a problem in CableSwig that did not recognize it as such.  I have checked
in a fix to CableSwig.


-Bill