[Insight-users] vnl differences from VS2008 and command prompt

Bill Lorensen bill.lorensen at gmail.com
Wed Sep 8 07:56:54 EDT 2010


Post a complete, compilable example with input parameters and we can
take a look.

On Mon, Aug 30, 2010 at 7:42 PM, John D <john.dz.eis at gmail.com> wrote:
> Hi all,
>
>   I am using some vnl calls and the results when I use the Visual Studio
> 2008 Debugger is different from the results if I run the program at the
> command prompt. The iresults I get from the debugger seem to be the correct
> one.
>
> I am trying to decompose an affine matrix into its components and here is
> the code:
>
>      //Compute the rotation angle and scaling from SVD of the matrix.
>         vnl_matrix<double> p(2, 2);
>         p[0][0] = (double) vOutputParameters[0];
>         p[0][1] = (double) vOutputParameters[1];
>         p[1][0] = (double) vOutputParameters[2];
>         p[1][1] = (double) vOutputParameters[3];
>         vnl_svd<double> svd(p);
>         vnl_matrix<double> r(2, 2);
>
>         vnl_matrix<double> scalingDiag(2, 2);
>         scalingDiag[0][0] = svd.W(0);
>         scalingDiag[1][1] = svd.W(1);
>
>         vnl_matrix<double> scalingMat(2, 2);
>         scalingMat = svd.V()*scalingDiag*vnl_transpose(svd.V());
>
>         vnl_matrix<double> rotationMat(2,2);
>         rotationMat = svd.U()*vnl_transpose(svd.V());
>         double angle    = -atan(rotationMat[0][1]/rotationMat[0][0]);
>         double sinAngle = sin(angle);
>
>         std::cout << "  Lambda1 :  = " << svd.W(0)<< std::endl;
>         std::cout << "  Lambda2 :  = " << svd.W(1)<< std::endl;
>         std::cout << "  V :  = " << svd.V()<< std::endl;
>         std::cout << "  U :  = " << svd.U()<< std::endl;
>
>         std::cout << " Scale 1         = " << scalingMat[0][0]
> << std::endl;
>         std::cout << " Scale 2         = " << scalingMat[1][1]
> << std::endl;
>         std::cout << " Angle (degrees) = " << angle * 45.0 / atan(1.0)
>     << std::endl;
>         std::cout << " Skew X          = " << scalingMat[0][1]
>     << std::endl;
>         std::cout << " Skew Y          = " << scalingMat[1][0]
>     << std::endl;
>
> scalingMat should be symmetric..which is the result I get from the debugger
> (The code is compiled as release and the debugger is running from the same
> directory which I use
> to run from the commandline also)
>
> For ex:
> [ 0.99307       0.00623954;
>   0.00623954  0.996727];
>
> However from the command prompt, I get the following:
> [0.992893    0.810226;
>  -0.798249   0.996677];
>
> Has anybody had problems like this before ? How can it be fixed?
> Thanks,
> John
>
>
>
>
>
> _____________________________________
> 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.html
>
> 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://www.itk.org/mailman/listinfo/insight-users
>
>


More information about the Insight-users mailing list