Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Examples/RegistrationITKv4/ImageRegistration9.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
// that will monitor the evolution of the registration process.
//
#include "itkCommand.h"
#include "itkMathSVD.h"
class CommandIterationUpdate : public itk::Command
{
public:
Expand Down Expand Up @@ -112,9 +113,9 @@ class CommandIterationUpdate : public itk::Command
p[0][1] = static_cast<double>(optimizer->GetCurrentPosition()[1]);
p[1][0] = static_cast<double>(optimizer->GetCurrentPosition()[2]);
p[1][1] = static_cast<double>(optimizer->GetCurrentPosition()[3]);
vnl_svd<double> svd(p);
const auto svd = itk::Math::SVD(p);
vnl_matrix<double> r(2, 2);
r = svd.U() * vnl_transpose(svd.V());
r = svd.U * svd.V.transpose();
const double angle = std::asin(r[1][0]);
std::cout << " AffineAngle: " << angle * 180.0 / itk::Math::pi
<< std::endl;
Expand Down Expand Up @@ -411,9 +412,9 @@ main(int argc, char * argv[])
p[0][1] = static_cast<double>(finalParameters[1]);
p[1][0] = static_cast<double>(finalParameters[2]);
p[1][1] = static_cast<double>(finalParameters[3]);
vnl_svd<double> svd(p);
const auto svd = itk::Math::SVD(p);
vnl_matrix<double> r(2, 2);
r = svd.U() * vnl_transpose(svd.V());
r = svd.U * svd.V.transpose();
const double angle = std::asin(r[1][0]);

const double angleInDegrees = angle * 180.0 / itk::Math::pi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ CanonicalizeEigenvectorColumnSigns(vnl_matrix<T> & V)
/** Same canonicalization as \c CanonicalizeEigenvectorColumnSigns, applied to \a u,
* with the identical per-column flip mirrored onto \a paired so a factor pair (e.g.
* the U and V of an SVD) stays
* consistent. Templated on the matrix type so it serves vnl_matrix and
* vnl_matrix_fixed; the sign is well-defined only when the leading per-column
* consistent. Templated on the matrix types so it serves vnl_matrix and
* vnl_matrix_fixed, including pairs of distinct fixed types (a rectangular SVD's
* U and V); the sign is well-defined only when the leading per-column
* magnitude is unambiguous (distinct singular values). */
template <typename TMatrix>
template <typename TMatrixU, typename TMatrixV>
void
CanonicalizeColumnSignsPaired(TMatrix & u, TMatrix & paired)
CanonicalizeColumnSignsPaired(TMatrixU & u, TMatrixV & paired)
{
// u and paired share a column count but may differ in row count (an SVD's
// thin U is rows x k, V is cols x k), so each is flipped over its own rows.
Expand All @@ -75,7 +76,7 @@ CanonicalizeColumnSignsPaired(TMatrix & u, TMatrix & paired)
pivot = i;
}
}
if (u(pivot, j) < typename TMatrix::element_type{ 0 })
if (u(pivot, j) < typename TMatrixU::element_type{ 0 })
{
for (unsigned int i = 0; i < uRows; ++i)
{
Expand Down
Loading
Loading