[Insight-users] Odd java wrappers behavior

Brian Eastwood beastwoo at email.unc.edu
Wed Jul 21 12:12:01 EDT 2004


Hi Luis,

Sorry it took so long for me to answer, but I was not able to verify 
that the problem has been fixed.  With a new CVS update I still found 
the same behavior I outlined before--I can read through a set of 
transforms perfectly well, but after I instantiate an object I receive 
an error when trying to execute the same code.

Incidently, I'm more interested now in writing pipelines in C++ and 
wrapping them in Java for a GUI.  You mentioned a while ago that a Java 
application example was under development--do you know when that might 
be ready so I can see how to configure cmake, cswig, etc.

Thanks a lot,
Brian

Luis Ibanez wrote:

> Hi Brian,
>
> A bug was recently fixed in the Java wrapping.
> It was affecting the way dynamic casting occurs.
>
> It is likely that this bug was related to the odd
> behavior that you reported in your example with
> Transforms.
>
> If you have a chance, could you please update
> your CVS checkout and verify if the problem has
> been solved ?
>
> Please let us know what you find.
>
>
>   Thanks,
>
>
>      Luis
>
>
> ---------------------
> Brian Eastwood wrote:
>
>> Hi Luis,
>>
>> Here's a little background: I'm using registration to align a video 
>> sequence.  I have a class that generates a list of transforms, one 
>> for each frame.  I first ran across this problem when I tried to use 
>> this list of transforms to generate a modified sequence (using 
>> itkResampleImageFilter)--I first saw the problem when I was trying to 
>> compose the transforms.
>>
>> Now I simply save the transform data to a file--this works better for 
>> me anyway, since I may want to use the same transforms on a different 
>> file sequence that may not be otherwise registered (different image 
>> data, same capturing method).  One line of my output file looks like:
>>
>> InsightToolkit.itkCenteredRigid2DTransform 5: -0.0054248555345777095, 
>> 111.99813266896304, 114.49967542970687, 0.14514270891024816, 
>> -0.6813850112138921
>>
>> So, we have the class name, the number of parameters, and then the 
>> actual transform parameters.  Here's the method I use to read this file:
>>
>>    public static List loadTransforms(String fileName)
>>    {
>>        List transforms = new ArrayList();
>>        try
>>        {
>>            BufferedReader reader = new BufferedReader(new 
>> FileReader(fileName));
>>            String line;
>>            String delims = " " + OBJECT_DELIM + ATTRIB_DELIM; // 
>> space, colon, comma
>>            while ((line = reader.readLine()) != null)
>>            {
>>                StringTokenizer tokenizer = new StringTokenizer(line, 
>> delims);
>>                String xformClass = tokenizer.nextToken(); // ignored
>>                int paramCount = Integer.parseInt(tokenizer.nextToken());
>>                              // @todo Maybe handle other types of 
>> transforms?
>>                itkCenteredRigid2DTransform_Pointer transform = 
>> itkCenteredRigid2DTransform.itkCenteredRigid2DTransform_New();
>>                transform.SetIdentity();
>>                itkArrayD params = new itkArrayD(paramCount);
>>                              for (int i = 0; i < paramCount; i++)
>>                {
>>                    params.SetElement(i, 
>> Double.parseDouble(tokenizer.nextToken()));
>>                }
>>                              transform.SetParameters(params);
>>                transforms.add(transform.GetPointer());
>>            }
>>                      reader.close();
>>        }
>>        catch (IOException ioe)
>>        {
>>            System.err.println("RegistrationOutput: IO exception 
>> occurred:");
>>            ioe.printStackTrace();                  }
>>              System.out.println(transforms.size() + " transforms read 
>> from file " + fileName + ".");
>>        return transforms;
>>    }
>>
>> With this list of transforms I run across the same problems as with 
>> the list I obtain directly from registration--I can do certain 
>> things, but at some point I might get that odd error.  Here's an 
>> extended example of the code block I gave yesterday:
>>
>>        System.out.println("\n--- Before ---");
>>        TransformIO.printTranforms(transforms);
>>              reader = 
>> itkImageFileReaderUS2.itkImageFileReaderUS2_New(); // this one is 
>> instantiated
>>        caster = null; // 
>> itkCastImageFilterUS2F2.itkCastImageFilterUS2F2_New();
>>        rescaler = null; // 
>> itkRescaleIntensityImageFilterF2US2.itkRescaleIntensityImageFilterF2US2_New(); 
>>
>>        writer = null; // 
>> itkImageFileWriterUS2.itkImageFileWriterUS2_New();
>>              System.out.println("\n--- After ---");
>>        TransformIO.printTranforms(transforms);
>>        if (true) return;
>>
>> When I run this, all of the transforms print out from the "before" 
>> group; six print out from the "after" group before it crashes.  If I 
>> instantiate the caster instead, only one transform prints out from 
>> the "after" group.  If I don't instantiate any objects, all 
>> transforms print out.  That's why I'm scratching my head so much on 
>> this one.
>>
>> Thanks, again, for your help.
>> Cheers,
>> Brian
>>
>
>
>


-- 
________________________________________
                      < brian eastwood >
          < beastwoo at cs . unc . edu >
       < beastwoo at email . unc . edu >
     < http://www.cs.unc.edu/~beastwoo >
                    < 919 . 962 . 1761 >



More information about the Insight-users mailing list