[Insight-users] Java wrappers import/export data
Alejandro Canales Ochoa
aco at cion.com.mx
Tue, 2 Mar 2004 01:33:03 -0600
Thank you very much Luis, I was start to think that I was alone with this.
You are right. I was trying to read a PNG image with an unsigned short reader. I did that way because the sample in chapter seven of the ITK guide do the first sample with that kind of reader, I also tried with an F2 reader with the same result (in fact you can not read with an F2 reader and write with an US2 writer). What I did not try was with other kind of image :-(
I don’t know that the wrappers were only for prototyping purposes. In fact I was very excited with the possibility to use ITK in my application, which is not for prototyping only, nor is intended for commercial use; the app is for internal use here at UAM (Universidad Autonoma Metropolitana – Mexico, D.F.), specifically for the biomedical department.
The main goal of my project is to implement a test bed application where the researchers can test new algorithms without need to reinvent the wheel or use Matlab for that, using the ITK features to help in this task. In fact in the short future I will implement an segmentation algorithm that was published in March’s IEEE transactions of biomedical Engineering authored by my direct advisors (by the way, they are very interested in THE INSIGHT, as it took two years to see their article published).
The app is currently under development and I choose Java for implementing it. The decision was made because is intended that the application can be easily modified by students, with few experience in advanced C++.
I already have done an application where you can use some segmentation methods or filters provided by ITK. The application haves a framework in which you can plug in new processes like segmentation or filtering. The ITK plugins I have developed are based in the JNI paradigm or by directly calling “exe” files. When I heard about the java wrappers I said “Hey, that’s exactly what I need!”.
For display purposes I am using JAI (as you guess). I am thinking that I can read and maintain all the images within ITK (as long as ITK provides me with a plethora of reader/writers) and mainly export the data for visualization (via the JAI API).
I am using volumes and Images (from many formats –PNG, RAW, JPEG, etc-), so at least for now the best way the wrappers can expose me the image is as a plain buffer, a DataBuffer or as a PlanarImage. It’s a plus if I can do the coronal & sagital views using the ImageExtractFilter with no problem.
Also I need to import images not generated with ITK in order to connect it to an ITK pipeline, for that purpose the ImportImageFilter fits all my requirements, maybe for this moment I can use a temporary file in order to achieve this, but as you can see is not the optimal way.
I am very pleased for your attention and believe me is very important for me that this *little* things works in the java wrappers.
I am a newbie in ITK but as long as I can see many messages are asking for a GUI for ITK and I am sure many people are working in this task (like me). So, why Java cannot be a choice for develop a full ITK application?
The first look I took to ITK was six months ago, and I was developing native libraries to access some ITK functionality from Java. It was a very tedious task since I need to encapsulate the instantiation of the ITK types from java with a plethora of switch sentences. The work you have done with the java wrappers is amazing, so I think the import/export feature will be a very nice thing.
In the case you at Kitware can implement my requirements, when can it will be done? Can I help in any way (except by no asking)? The case is that I need to deliver the app within two months, so I need to make some decisions here.
Well, thanks for hear me and THANKS AGAIN!
Alejandro Canales
El Mon, 01 Mar 2004 20:38:39 -0500, luis.ibanez at kitware.com escribio:
>
>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
>>
>
>
>
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>