[Insight-users] Question about Java Wrapping I/O

Sean Doyle sdoyle at medcommons.org
Sun Jul 1 19:43:35 EDT 2007


Is there a way that I can pass a stream reference instead of a file
reference to the ITK wrapped classes?

I have a server written in Java which needs to process DICOM files. What
would be ideal would be for ITK to be invoked with a Java stream instead of
a File reference and for the output to be similarly returned as a stream (so
that it could be placed in an output HTTP stream). Is there an exposed
interface for doing this? I don't see one (but it might be right in front of
me and I've missed it).

Conceptually  - something like this is what I'm looking for:

void processStream(InputStream in, OutputStream out){

   itkImageFileReaderF2_Pointer reader =
itkImageFileReaderF2.itkImageFileReaderF2_New ();
   reader.setInputStream(in);

  itkImageFileWriterUC2_Pointer writer =
itkImageFileWriterUC2.itkImageFileWriterUC2_New();
  writer.setOutputStream(out);
}

But I don't know that the JNI interfaces for this could be nearly so clean.
Perhaps the NIO interfaces might have something that could be passed via JNI
to C++ - but it's been a while since I've looked at this.

Alternatively - I guess I could have a process running the ITK code which
accepted socket connections and I could basically set up my pipeline calling
out to this process as a filter.

Finally - I guess I could embed it in an Apache HTTPD server and do a HTTP
redirect - but putting things in Java so I can manage the IO streams from
Tomcat would fit in best with my current software.

Some of the images are on the large size (20+MB) so I don't want to deal
with the latency of writing out to a file so that ITK can read it in; some
images are small so I don't want to launch an external process for each
image.

Suggestions welcomed. Thanks.

Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070701/d3fceec1/attachment.html


More information about the Insight-users mailing list