[Insight-users] itk::CenteredRigid2DTransform is Linear?
Constantine Zakkaroff
mnkz at leeds.ac.uk
Thu Apr 12 08:09:49 EDT 2012
Hello ALL.
The definition of IsLinear method of itk::CenteredRigid2DTransform is
inherited from itk::MatrixOffsetTransformBase class, where it is defined
very simply as this:
/** Indicates that this transform is linear. That is, given two
* points P and Q, and scalar coefficients a and b, then
*
* T(a*P + b*Q) = a * T(P) + b * T(Q)
*/
virtual bool IsLinear() const { return true; }
However, the equality
T( a*P + b*Q ) = a * T(P) + b * T(Q)
does not appear valid from what I can see with maths involved into the
transform computations.
Also, the following code example below confirms the equality does not
stand for itk::CenteredRigid2DTransform, producing the following output:
[56.173, -382.694] =?= [137.372, -306.153]
typedef itk::Point<double, 2> PtT;
typedef itk::Vector<double, 2> VT;
typedef itk::CenteredRigid2DTransform<double> TTrfT;
TTrfT::Pointer trf = TTrfT::New();
PtT pt;
pt[0] = 50;
pt[1] = 60;
trf->SetCenter(pt);
VT trns;
trns[0] = 10;
trns[1] = 20;
trf->SetTranslation(trns);
trf->SetAngle(0.1);
PtT P;
P[0] = 100;
P[1] = 200;
double a = 2;
PtT Q;
Q[0] = -50;
Q[1] = -200;
double b = 4;
std::cout << std::setprecision(3) << std::fixed;
std::cout << trf->TransformPoint(PtT((a * P.GetVectorFromOrigin() + b *
Q.GetVectorFromOrigin()).GetDataPointer())) << " =?= ";
std::cout << PtT((a * trf->TransformPoint(P).GetVectorFromOrigin() + b *
trf->TransformPoint(Q).GetVectorFromOrigin()).GetDataPointer()) <<
std::endl;
Is it a bug?
Regards,
Constantine
More information about the Insight-users
mailing list