[ITK] [ITK-users] SimpleITK JAVA ImageRegistrationMethod --> after ResampleImageFilter, how?

ivan ivan.granata.na at gmail.com
Sun Oct 9 02:43:30 EDT 2016


i tried to write a registration with simple ITK java code with
ImageRegistrationMethod

in input i've fixedimage movingimage 
in output i've a trasform.txt file


transform.txt contains these informations:



but as final output i want an image coreg not just a parameters in txt

so i read ResampleImageFilter for this goal  (i think is good) but in java i
don't understand how i can integrate in my code

Plese someone can help me?




this is my code



import org.itk.simple.*;


class IterationUpdate  extends Command {

  private ImageRegistrationMethod m_Method;

  public IterationUpdate(ImageRegistrationMethod m) {
    super();
    m_Method=m;
  }

  public void execute() {
    org.itk.simple.VectorDouble pos = m_Method.getOptimizerPosition();
    System.out.format("%3d = %10.5f : [%f, %f]\n",
                      m_Method.getOptimizerIteration(),
                      m_Method.getMetricValue(),
                      pos.get(0), pos.get(1));
  }
}

class ImageRegistrationMethodNaplab {

  public static void main(String argv[]) {

  if ( argv.length < 3 )
    {
      System.out.format( "Usage: %s <fixedImageFilter> <movingImageFile>
<outputTransformFile>\n", "ImageRegistrationMethodNaplab");
      System.exit(-1);
    }

  org.itk.simple.ImageFileReader reader = new
org.itk.simple.ImageFileReader();
  reader.setOutputPixelType( PixelIDValueEnum.sitkFloat32 );

  reader.setFileName(argv[0]);
  Image fixed = reader.execute();

  reader.setFileName(argv[1]);
  Image moving = reader.execute();

  org.itk.simple.ImageRegistrationMethod R = new 
org.itk.simple.ImageRegistrationMethod();
  R.setMetricAsMattesMutualInformation();
  double maxStep = 4.0;
  double minStep = 0.001;
  int numberOfIterations = 200;
  double relaxationFactor = 0.5;
  R.setOptimizerAsRegularStepGradientDescent( maxStep,
                                              minStep,
                                              numberOfIterations,
                                              relaxationFactor );
  R.setInitialTransform( new org.itk.simple.TranslationTransform(
fixed.getDimension() ) );
  R.setInterpolator( InterpolatorEnum.sitkLinear );

  IterationUpdate cmd = new IterationUpdate(R);
  R.addCommand( EventEnum.sitkIterationEvent, cmd);

  org.itk.simple.Transform outTx = R.execute( fixed, moving );

  System.out.println("-------");
  System.out.println(outTx.toString());
  //System.out.format(" Fixed Initial Transform: %d\n",
R.getFixedInitialTransform());
  //System.out.format(" Moving Initial Transform: %d\n",
R.getMovingInitialTransform());
  //System.out.format(" Initial Transform: %d\n", R.getInitialTransform());
  System.out.format(" Optimizer Position: %d\n", R.getOptimizerPosition());
  System.out.format("Optimizer stop condition: %s\n",
R.getOptimizerStopConditionDescription());
  System.out.format(" Iteration: %d\n", R.getOptimizerIteration());
  System.out.format(" Metric value: %f\n", R.getMetricValue());
  System.out.format(" Interpolator: %f\n", R.getInterpolator());
  //System.out.format(" Translation X", R.getTranslationAlongX());
 // System.out.format(" Translation Y", R.getTranslationAlongY());
  outTx.writeTransform(argv[2]);
  System.out.println("Parametri Trasformazione Generati e Salvati");
 
  //org.itk.simple.Transform.writeTransform(argv[4]);
  //org.itk.simple.ResampleImageFilter image = new
org.itk.simple.ResampleImageFilter();
  //image.setOutputPixelType( PixelIDValueEnum.sitkFloat32 );
 // image.getOutputPixelType(); 
 // image.getSize ();

  //ImageFileWriter writer = new ImageFileWriter();

 // writer.setFileName(argv[5]);
  



  }  

  
 
  
  
  
  
}
  



--
View this message in context: http://itk-users.7.n7.nabble.com/ITK-users-SimpleITK-JAVA-ImageRegistrationMethod-after-ResampleImageFilter-how-tp37655.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list