[ITK] ITK bug or feature

Yaniv, Ziv Rafael (NIH/NLM/LHC) [C] zivrafael.yaniv at nih.gov
Thu Sep 14 12:34:07 EDT 2017


Hello ITK developers,

I encountered unexpected behavior with ITK parameter settings in degenerate cases for the CenteredSimilarity2DTransform and Similarity3DTransform classes.

The degenerate parameter values I am referring to is setting the scale to zero. I encountered this issue when I blindly set all parameters to zero to get an identity transform (obviously scale should be one). It appears that setting the scale factor to zero is acceptable, no exception (arbitrary choice which makes sense for the general SetParameters method – up to the user to make sure the parameter values make sense).

The feature/bug I am referring to has to do with the GetInverse method (ill-defined for this degenerate case):

2D case -  when I print the original transformation, it is identified as singular. When I invoke the GetInverse method vnl generates a warning with the resulting “inverse” transform including Nan and Inf , not identified as singular.

3D case -  when I print the original transformation, it is identified as singular. When I invoke the GetInverse method there is no warning and the “inverse” transform has numbers and is identified as singular.

Is this behavior fine and up to the user to deal with? Should the GetInverse generate an exception?
        thanks
             Ziv

Code for the two cases below:

    {
    typedef itk::Similarity3DTransform<double> TransformType3D;
    // Test degenerate parameter settings
    TransformType3D::Pointer t1 = TransformType3D::New();
    TransformType3D::Pointer t1Inverse = TransformType3D::New();

    // Set parameters
    TransformType3D::ParametersType parameters( t1->GetNumberOfParameters() );
    // Degenerate configuration with zero scale
    parameters[0] = 1.0;
    parameters[1] = 0.0;
    parameters[2] = 0.0;
    parameters[3] = 1.0;
    parameters[4] = 2.0;
    parameters[5] = 3.0;
    parameters[6] = 0.0; //scale

    t1->SetParameters( parameters );
    t1Inverse->SetParameters(parameters);

    t1->GetInverse( t1Inverse );
    std::cout<< "**original**\n"<<t1;
    std::cout<< "**inverse**\n"<<t1Inverse<<"\n";
    }

    {
    // Test degenerate parameter settings
    typedef itk::CenteredSimilarity2DTransform<double> TransformType2D;
    TransformType2D::Pointer t1 = TransformType2D::New();
    TransformType2D::Pointer t1Inverse = TransformType2D::New();

    // Set parameters
    TransformType2D::ParametersType parameters( t1->GetNumberOfParameters() );
    // Degenerate configuration with zero scale
    parameters[0] = 0.0; //scale
    parameters[1] = -21.0 / 180.0 * itk::Math::pi;
    parameters[2] = 12.0;
    parameters[3] = -8.9;
    parameters[4] = 67.8;
    parameters[5] = -0.2;

    t1->SetParameters( parameters );
    t1->GetInverse( t1Inverse );
    std::cout<< "**original**\n"<<t1;
    std::cout<< "**inverse**\n"<<t1Inverse<<"\n";
    }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170914/27ca341d/attachment.html>


More information about the Community mailing list