36 #ifndef VIGRA_AFFINEGEOMETRY_HXX 37 #define VIGRA_AFFINEGEOMETRY_HXX 39 #include "mathutil.hxx" 41 #include "tinyvector.hxx" 42 #include "splineimageview.hxx" 43 #include "multi_shape.hxx" 66 linalg::TemporaryMatrix<double> ret(identityMatrix<double>(3));
79 linalg::TemporaryMatrix<double> ret(identityMatrix<double>(3));
80 ret(0,0) = scalingFactor;
81 ret(1,1) = scalingFactor;
92 linalg::TemporaryMatrix<double> ret(identityMatrix<double>(3));
105 linalg::TemporaryMatrix<double> ret(identityMatrix<double>(3));
118 linalg::TemporaryMatrix<double> ret(identityMatrix<double>(3));
165 template <
int ORDER,
class T,
166 class DestIterator,
class DestAccessor>
168 DestIterator
id, DestAccessor dest,
174 double angle = angleInDegree/180.0;
178 for(
int y = 0; y < h; ++y, ++
id.y)
180 typename DestIterator::row_iterator rd =
id.rowIterator();
181 double sy = (y - center[1])*c - center[0]*s + center[1];
182 double sx = -(y - center[1])*s - center[0]*c + center[0];
183 for(
int x=0; x < w; ++x, ++rd, sx += c, sy += s)
186 dest.set(src(sx, sy), rd);
191 template <
int ORDER,
class T,
192 class DestIterator,
class DestAccessor>
195 pair<DestIterator, DestAccessor> dest,
198 rotateImage(src, dest.first, dest.second, angleInDegree, center);
201 template <
int ORDER,
class T,
202 class DestIterator,
class DestAccessor>
205 DestIterator
id, DestAccessor dest,
206 double angleInDegree)
209 rotateImage(src,
id, dest, angleInDegree, center);
212 template <
int ORDER,
class T,
213 class DestIterator,
class DestAccessor>
216 pair<DestIterator, DestAccessor> dest,
217 double angleInDegree)
220 rotateImage(src, dest.first, dest.second, angleInDegree, center);
223 template <
int ORDER,
class T,
230 rotateImage(src, destImage(dest), angleInDegree, center);
233 template <
int ORDER,
class T,
238 double angleInDegree)
241 rotateImage(src, destImage(dest), angleInDegree, center);
365 template <
int ORDER,
class T,
366 class DestIterator,
class DestAccessor,
369 DestIterator dul, DestIterator dlr, DestAccessor dest,
373 affineMatrix(2,0) == 0.0 && affineMatrix(2,1) == 0.0 && affineMatrix(2,2) == 1.0,
374 "affineWarpImage(): matrix doesn't represent an affine transformation with homogeneous 2D coordinates.");
377 double w = dlr.x - dul.x;
378 double h = dlr.y - dul.y;
380 for(
double y = 0.0; y < h; ++y, ++dul.y)
382 typename DestIterator::row_iterator rd = dul.rowIterator();
383 for(
double x=0.0; x < w; ++x, ++rd)
385 double sx = x*affineMatrix(0,0) + y*affineMatrix(0,1) + affineMatrix(0,2);
386 double sy = x*affineMatrix(1,0) + y*affineMatrix(1,1) + affineMatrix(1,2);
388 dest.set(src(sx, sy), rd);
393 template <
int ORDER,
class T,
394 class DestIterator,
class DestAccessor,
398 triple<DestIterator, DestIterator, DestAccessor> dest,
401 affineWarpImage(src, dest.first, dest.second, dest.third, affineMatrix);
404 template <
int ORDER,
class T,
412 affineWarpImage(src, destImageRange(dest), affineMatrix);
REAL sin_pi(REAL x)
sin(pi*x).
Definition: mathutil.hxx:1166
bool isInside(double x, double y) const
Definition: splineimageview.hxx:487
unsigned int width() const
Definition: splineimageview.hxx:400
MultiArrayIndex rowCount(const MultiArrayView< 2, T, C > &x)
Definition: matrix.hxx:669
linalg::TemporaryMatrix< T > sin(MultiArrayView< 2, T, C > const &v)
Definition: accessor.hxx:43
REAL cos_pi(REAL x)
cos(pi*x).
Definition: mathutil.hxx:1204
MultiArrayIndex columnCount(const MultiArrayView< 2, T, C > &x)
Definition: matrix.hxx:682
Base class for, and view to, vigra::MultiArray.
Definition: multi_array.hxx:655
Create a continuous view onto a discrete image using splines.
Definition: splineimageview.hxx:99
linalg::TemporaryMatrix< T > cos(MultiArrayView< 2, T, C > const &v)
unsigned int height() const
Definition: splineimageview.hxx:406