[Insight-users] Re: On Metrics of registration

cspl affable at hd2 . dot . net . in
Tue, 27 Aug 2002 11:17:24 +0530


Dear Mr.Luis,
   I have done the same process as you specified in your mail.But,I could
not get the output.I am getting problem at start registration.when I tried
to run the application on windows98 system,I am getting error message "this
program has performed an illegal operation".Even i could not catch the error
message using try catch. I am enclosing the code.Please check my code and
suggest any modifications in the code.


--------code---------


typedef itk::NormalizedCorrelationImageToImageMetric<ImageType, ImageType>
MetricType;

typedef itk::QuaternionRigidTransform<double> TransformType;

typedef itk::QuaternionRigidTransformGradientDescentOptimizer OptimizerType;

typedef itk::LinearInterpolateImageFunction<ImageType, double>
InterpolatorType;

 TransformType::Pointer      transform     = TransformType::New();
OptimizerType::Pointer      optimizer     =  OptimizerType::New();
 InterpolatorType::Pointer   interpolator  = InterpolatorType::New();
 MetricType::Pointer         metric = MetricType::New();

     RegistrationType1::ParametersType
guess(transform->GetNumberOfParameters() );

     guess[0] = 0.0;
     guess[1] = 0.0;
     guess[2] = 0.0;
     guess[3] = 1.0;
     guess[4] = 1.0;
     guess[5] = 1.0;
     guess[6] = 0.0;

     registration->SetInitialTransformParameters (guess);

    // Set translation scale
    typedef OptimizerType::ScalesType ScaleType;
    ScaleType scales(transform->GetNumberOfParameters());
    scales.Fill( 1.0 );
    for( unsigned j = 4; j < 7; j++ )
    {
     scales[j] = 1.0 / vnl_math_sqr(1000.0);
    }


    //Scale parameters
    optimizer->SetNumberOfIterations(1000);
    optimizer->SetLearningRate( 0.0000001 );

    // Setup the optimizer
    optimizer->SetScales(scales);
    // optimizer->MaximizeOn();
                //set metric parameters
       metric->SetFixedImageRegion(FixedImage->GetBuffer());

    //set registration parameters
                registration->SetMetric(metric);
    registration->SetOptimizer(optimizer);
    registration->SetTransform(transform);
    registration->SetInterpolator(interpolator);
    registration->SetFixedImage(FixedImage);
    registration->SetMovingImage(MovingImage);

    try
    {
     registration->StartRegistration();
    }
    catch(itk::ExceptionObject &except)
    {
            std::cerr<<"Exception"<<except.GetDescription();


    }




----- Original Message -----
From: "Luis Ibanez" <luis.ibanez@kitware.com>
To: "cspl" <affable@hd2.dot.net.in>
Cc: <insight-users@public.kitware.com>
Sent: Monday, August 26, 2002 8:52 PM
Subject: Re: On Metrics of registration


>
> Hi Cspl,
>
>
> The Image Metrics used by the registration framework
> share a basic common API. However, depending on the
> specific concept they evaluate, metrics will require
> additional parameters that users must provide.
>
> MutulaInformation works by randomply sampling pixels
> from the images.For this reason this particular metric
> has a "SetNumberOfSamples()" method.  The other metrics:
> MeanSquares and NormalizedCorrelation do not subsample
> the images and henceforth they do not have this method.
>
> The same situation arises with SetFixedImageStandardDeviation
> which is used by the MutualInformation class in order
> to get a value that will help to estimate the joint
> probabilities of gray levels betwen the images.
> The othere metrics do not require to estimate joint
> probabilities, so they do not have these methods.
>
> If you are modifying the ImageRegistration example
> in order to replace the MI metric for another one,
> just remove the method calls that are not applicable
> to the new metric you want to test.
>
>
> BTW Just for the record, the pixel sampling performed
> by MI is just a speed up of the basic way of computing
> the metric. This is the implementation of the Viola &
> Wells paper.  The same speed up could be applied to
> any of the other metrics that currently visit all the
> pixels in the fixed image. A random sampling would
> largely reduce the computing time for registration
> of metrics like MeanSquares and NormalizedCorrelation.
>
>
> Please let us know if you find any other problem.
>
>
> Thanks
>
>
>    Luis
>
>
>
> ----------------
>
> ====================================================================
>
> Dear Mr.Luis,
>
>   I am working on itkImageRegistration with different metric classes as
> metrics for registration.I could get the output with
> itkMutualInformationImageToImageMetric class.But,I am getting error
> when i used itkNormalizedCorrelationImageToImageMetric and
> itkMeanSquaresImageToImageMetric.I found that some classes like
> setFixedImagestandarddeviation,setNumberOfSamples etc are not available
> in Normal and meansquares.I am getting problem at startregistration().
>
> I am unable to catch the exception using try and catch.I am getting some
> memory exception.I am enclosing  code.
>
>
>
>
>
>