[Insight-users] AddObserver + JAVA

Li, George (NIH/NCI) ligeorge at mail.nih.gov
Wed Jan 26 16:21:37 EST 2005


Oliveira:

The JNI code, obviously, will be machine dependent.
That is the drawback you have to take. 

A lot of things about JNI has to be learnt in order
to get this done right. Basically, on the C++ side,
you have to create a dll, which contains all the JNI
ITK code. On the Java side, you can create native
call functions, associated with the JNI dll. A lot
of reading has to be done on JNI and ITK architecture. 
Fortunately, some on-line forums might be helpful to 
you.

It can Be very tricky once you get into data format
in function calls. It is really like a new language,
in the sense of data communication. My experience 
with JNI, unfortunately, is not related with ITK, at
least for now.

Another option you have, if you don't mind, is to
switch to C++ to do the back end work, and then pass
the processed data to you jave code in whatever way 
you would like to.

It is always easy to say, but hard to do.

Good luck.

George


-----Original Message-----
From: Oliveira Marcelo [mailto:marceloitk at yahoo.com.br] 
Sent: Wednesday, January 26, 2005 1:50 PM
To: Li, George (NIH/NCI)
Cc: insight-users at itk.org
Subject: RE: [Insight-users] AddObserver + JAVA


 Hi Li and users!!!

Taxs a lot for your replay, this help me a lot!!!
I´d been learn a lot about JNI. But i think that a
need examples how can i use JNI with ITK. Do you or
anyone could show me an example of ITK JAVA and JNI.

tanx a lot

best regards



--- "Li, George (NIH/NCI)" <ligeorge at mail.nih.gov>
escreveu: 
> Oliveira:
> 
> You can always use JNI to communicate your JAVA code
> with ITK C++ code. It might be a good option for you
> to by-pass the hurdle for the translation, which may
> be endless to keep up with their endless releases!!!
> 
> Regard.
> 
> George
> 
> 
> -----Original Message-----
> From: Oliveira Marcelo
> [mailto:marceloitk at yahoo.com.br]
> Sent: Tuesday, January 25, 2005 1:57 PM
> To: insight-users at itk.org
> Subject: [Insight-users] AddObserver + JAVA
> 
> 
> Hi Users !!!
> 
> Im try to write the MultiResImageRegistration1.cxx
> in
> JAVA, but i dont know how can work with AddObserver.
> 
> Please, is possible in the new itk version put more
> itk-java examples ? ill apreciated !!!
> 
> tanx a lot for your help and time !!!
> best regards
> 
> a piece of my code:
> 
> //*****  MAIN CODE  ************************
> 
> optimizer.AddObserver( new itkIterationEvent(), new
> CommandIterationUpdate() );
>          
> registration.AddObserver(new itkIterationEvent(),
> new
> RegistrationInterfaceCommand());
>         
>                  
> registration.SetNumberOfLevels( 3 );        
>           
> try
> { 
>              
>    registration.StartRegistration();
>             
> }
>  catch(Exception e)
> {
>    System.out.println("Error");
> }
> 
>
//***************************************************
> //****   CommandIterationUpdate Class
> //**************************************************
> 
> public class CommandIterationUpdate extends
> itkJavaCommand{
>  
>           
> public void Execute(final itkObject object, final itkEventObject 
> event) {
>                
>         itkRegularStepGradientDescentOptimizer
> optimizer;  
>         optimizer=
> (itkRegularStepGradientDescentOptimizer) object;
>         
>          itkIterationEvent it = new
> itkIterationEvent();
> 
>           if( (event) ==  (it)  )
>           {
>               return;
>           }
>         
>  System.out.print(optimizer.GetCurrentIteration());
>             System.out.print(optimizer.GetValue());
>            
> System.out.print(optimizer.GetCurrentPosition());
>          
>     }
>     
> }
> 
>
//***************************************************
> //****   RegistrationInterfaceCommand Class
> //**************************************************
> public class RegistrationInterfaceCommand extends itkJavaCommand{
>   
> private itkMultiResolutionImageRegistrationMethod
> registration;
>        
> public void Execute(itkObject object,final
> itkEventObject event)
>    {
>            
>        itkIterationEvent it = new
> itkIterationEvent();
> 
> 
>           if( (event) ==  (it)  )
>           {
>               return;
>           }
>           
>                 
>        itkRegularStepGradientDescentOptimizer
> optimizer;       
>        itkMultiResolutionImageRegistrationMethodF3F3
> reg;
>       
>    
>        reg =
> (itkMultiResolutionImageRegistrationMethodF3F3)
> object;
>      
>       
>        optimizer =
> (itkRegularStepGradientDescentOptimizer)
> reg.GetOptimizer();
>           
>        if( reg.GetCurrentLevel() == 0 )
>        {
>             
>               optimizer.SetMaximumStepLength( 16.00
> );
>  
>               optimizer.SetMinimumStepLength( 2.5 );
>        }
>        else
>        {
>              optimizer.SetMinimumStepLength(
> optimizer.GetCurrentStepLength() );
>              optimizer.SetMinimumStepLength( 
> optimizer.GetMinimumStepLength()/10.00 );
>           
>            
>        }
>           
>              
>    }
>     
> }
>            
> 
> 
> 	
> 	
> 		
>
_______________________________________________________
> 
> Yahoo! Acesso Grátis - Instale o discador do Yahoo!
> agora.
> http://br.acesso.yahoo.com/ - Internet rápida e
> grátis
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org 
> http://www.itk.org/mailman/listinfo/insight-users
>  

__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger 
http://br.download.yahoo.com/messenger/ 


More information about the Insight-users mailing list