[Insight-users] More on java wrappers

Luis Ibanez luis.ibanez at kitware.com
Mon, 01 Mar 2004 20:38:39 -0500


Hi Alejandro,

It is a common mistake to use images of pixel type
"unsigned short", save them as PNG files, and try
to look at them using standard viewers.  Most
viewers will not normalize the intensity range and
the resulting images will "look" black when they
have intensity values in the range of 8bits because
they get scaled to 16bits.

I wonder if you are running into this usual misleading
case. Please try using the reader/writer for UC2 (unsigned
char 2D), or using a viewer such as the ImageViewer
in InsightApplications which renormalize intensities, and
let us know if that works better for you.


You are right on the issue of importing/exporting data.
When the wrapping was designed, the main focus was put
on using Python/Tcl/Java for prototyping and education,
not really for writing real applications.  It should be
possible though to add the Import/Export filters to the
wrapping. That will probably makes more sense defined in
a language-by-language basis.


So, here is your lucky day:

                            Please suggest what would you
consider to be the ideal connection between an ITK image
and a Java class. I would guess that rather than giving
you access to the pointer of the pixel data, we could go
one step further and provide a connection to an actual
"Image" class in Java. Maybe something like the the
javax.media.jai.CollectionImage or the
javax.media.jai.PlanarImage.  Are you dealing with 3D
datasets ? or only with 2D images ?


Please let us know,


Thanks


   Luis



--------------------------------
Alejandro Canales Ochoa wrote:

> Hi everyone
> 
> This weekend I was trying to integrate ITK in my java application. The result is not very promising as I expected. The wrapper shows an inconsistent behavior, at least from the point of view of the Insight user’s guide; I was unable to complete some very basic examples. 
> For example, I try the Read-Write example and do not work at all. Here is my java code:
> 
> itkImageFileReaderUS2_Pointer reader = itkImageFileReaderUS2.itkImageFileReaderUS2_New();
> itkImageFileWriterUS2_Pointer writer = itkImageFileWriterUS2.itkImageFileWriterUS2_New();
> reader.SetFileName(args[0]);
> writer.SetFileName(args[1]);
> writer.SetInput(reader.GetOutput());
> writer.Update();
> 
> The output image is the same width and height as the original but is all black. After several trials I can get an image only if I use a filter (BinaryThreshold or CannyEdgeDetection for example) followed by the IntensityRescalerFilter. 
> 
> Another thing that is a mystery for me is how to import/export an image in/from the wrappers. As you can guess I *really* need to access pixel data (at least for displaying, not using VTK) and for feed the ITK filter from data that comes from my application. The ITK user’s guide shows the use of ImportImageFilter for importing the data, but this filter is missing (at least in my build). For accessing the pixel data the guide tells me that I need to use iterators, and shows how to create one, but the class itkImageRegionConstIterator is not present too. Either I don’t know how to make an instance of itkImageXX_Pointer from SWIGTYPE_p_itk__ImageTXXX_X_t, which is the type of the output in the filters, this for accessing via getPixel() method.
> 
> As you can see I am in a deep trouble because I can not make a substantial advance in my duty.
> 
> I hope someone can help me because, I am lost in those issues.
> 
> Regards and thanks in advance.
> Alejandro Canales
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>