[Insight-users] vnl differences from VS2008 and command prompt
John D
john.dz.eis at gmail.com
Mon Aug 30 19:42:42 EDT 2010
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100830/ee71170c/attachment.htm>
More information about the Insight-users
mailing list