[Insight-users] AddObserver + JAVA
Oliveira Marcelo
marceloitk at yahoo.com.br
Tue Jan 25 13:56:31 EST 2005
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
More information about the Insight-users
mailing list