25 #ifndef __TextureTransformEuclidian__hh__
26 #define __TextureTransformEuclidian__hh__
28 #include <Base/Common/BIASpragmaStart.hh>
29 #include <Image/TextureTransform.hh>
30 #include <Base/Common/CompareFloatingPoint.hh>
52 const double& sx = src[0];
53 const double& sy = src[1];
54 sink[0] =
A_[0][0]*sx +
A_[0][1]*sy +
tx_;
55 sink[1] =
A_[1][0]*sx +
A_[1][1]*sy +
ty_;
67 if (!
Equal(testsink[0]+1e-4,sink[0]+1e-4, 1e-4) ||
68 !
Equal(testsink[1]+1e-4,sink[1]+1e-4, 1e-4)) {
69 BIASERR(testsink<<
" and "<<sink<<
" are not equal with P="<<
P_
70 <<
" and src="<<src<<
" and A="<<
A_);
95 const double sinphi = sin(
P_[0]);
96 const double cosphi = cos(
P_[0]);
97 const double x = src[0]-
origin_[0];
98 const double y = src[1]-origin_[1];
100 Jac[0][0] = -sinphi*x-cosphi*y;
104 Jac[1][0] = cosphi*x-sinphi*y;
113 const double sinphi = sin(
P_[0]);
114 const double cosphi = cos(
P_[0]);
116 const double c13 =
P_[1];
117 const double c23 =
P_[2];
118 const double x = src[0]-
origin_[0];
119 const double y = src[1]-origin_[1];
121 Jac[0][0] = -sinphi*x+cosphi*y-cosphi*c23+c13*sinphi;
126 Jac[1][0] = -cosphi*x-sinphi*y+sinphi*c23+c13*cosphi;
142 BIASASSERT(p.
Size()==3);
144 A_[0][0] =
A_[1][1] = cos(p[0]);
145 A_[0][1] = -sin(p[0]);
146 A_[1][0] = -
A_[0][1];
150 tx_ = p[1]-offset[0];
151 ty_ = p[2]-offset[1];
168 A2[0][0] = A2[1][1] = cos(deltaP[0]);
169 A2[0][1] = -sin(deltaP[0]);
170 A2[1][0] = -A2[0][1];
173 A2[0][2] = deltaP[1]-(A2[0][0]-1.0)*
origin_[0]-A2[0][1]*
origin_[1];
174 A2[1][2] = deltaP[2]-A2[1][0]*origin_[0]-(A2[1][1]-1.0)*origin_[1];
176 A1 = A2.Invert() * A1;
179 p[0] =
P_[0]-deltaP[0];
180 p[1] = A1[0][2] + (A1[0][0]-1.0)*origin_[0] + A1[0][1]*origin_[1];
181 p[2] = A1[1][2] + A1[1][0]*origin_[0] + (A1[1][1]-1.0)*origin_[1];
194 const double cosine = cos(
P_[0]);
195 const double sine = sin(
P_[0]);
200 Jac[1][0] = sine*
P_[2]-cosine*
P_[2];
205 Jac[2][0] = cosine*P_[1]+sine*P_[2];
int Invert(Matrix2x2< T > &result) const
analyticaly inverts matrix
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
virtual TextureTransformEuclidian * Clone() const
virtual covariant copy constructor, caller must eventually destroy the created object ...
Vector< double > P_
current set of parameters, see SetParameters for meaning
Matrix< T > & newsize(Subscript M, Subscript N)
void ComposeWithInverseDeltaP(const Vector< double > &deltaP)
concatenate *this and an inverse transform with param deltaP and save new parameter vector to *this...
virtual bool TextureJacobianIsConstant() const
local warp is the same at any image position
TextureTransformEuclidian()
virtual ~TextureTransformEuclidian()
class for representing parameterized image warps, such as homography, displacement, ...
void SetOrigin(const Vector2< double > &origin)
origin relative to which rotation and scale is performed
unsigned int Size() const
length of the vector
Vector< T > & newsize(Subscript N)
double tx_
cached displacement and inverse
void SetZero()
Sets all values to zero.
int TextureJacobianBackward(const HomgPoint2D &sink, Matrix2x2< double > &Jac) const
shape change of the local region when mapping backward
int ParameterJacobianForward(Matrix< double > &Jac, const HomgPoint2D &src)
transformed position change when parameters change
Matrix2x2< double > Ainv_
Matrix2x2< double > A_
cached local warp and inverse
int MapForward(const HomgPoint2D &src, HomgPoint2D &sink) const
map a point in image "source" to a point in image "sink"
bool ParameterJacobianIsConstant() const
the jacobian depends on x
Vector2< double > origin_
origin relative to which rotation and scale is performed
bool Equal(const T left, const T right, const T eps)
comparison function for floating point values See http://www.boost.org/libs/test/doc/components/test_...
const Vector2< double > & GetOrigin() const
origin relative to which rotation and scale is performed
int ParameterInversionJacobian(Matrix< double > &Jac) const
compute parameters for inverse operation and obtain the jacobian of the inverse parameters with respe...
void SetParameters(const Vector< double > &p)
rotation(rad), scale-1, dx,dy.
int TextureJacobianForward(const HomgPoint2D &src, Matrix2x2< double > &Jac) const
shape change of the local region when mapping forward
int ParameterJacobianBackward(Matrix< double > &Jac, const HomgPoint2D &src)
transformed position change when parameters change
int MapBackward(const HomgPoint2D &sink, HomgPoint2D &src) const
map a point in image "source" to a point in image "sink"
analytic properties of Euclidian image warp (rot.