[Insight-users] Java wrappers import/export data

Alejandro Canales Ochoa aco at cion.com.mx
Thu, 4 Mar 2004 12:47:38 -0600


I have tried this, without any positive result

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);
SWIGTYPE_p_unsigned_char b = image.GetBufferPointer();
System.out.println("# REF: " + image.GetReferenceCount());

The program fails due a “segmentation fault” when the GetReferenceCount is made. 

Bill told me that there is not difficult for them to provide an API for importing/exporting images from/to java. He is figuring out how this API should be before implement it. I hope in the near future we can see that API.

So, how is your development?  How do you do the ITK-JAI bridge?

Regards
Alejandro Canales



El Thu, 04 Mar 2004 09:22:39 -0500, pablob at grasp.cis.upenn.edu escribio:
>Alejandro,
>
>I think that, if I undersatnd what you are trying to do well, one way 
>that may be helpful to access the data within an itkImage, may be 
>calling GetBufferPointer(). Have you tried that?
>
>Pablo
>
>Alejandro Canales Ochoa wrote:
>
>>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
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
>>  
>>
>
>______________________________________________________________________
>This email has been scanned by the MessageLabs Email Security System.
>For more information please visit http://www.messagelabs.com/email 
>______________________________________________________________________
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>