VIGRA - Geometric Transformations

[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]

| Geometric Transformations |
--- | --- | ---

## Functions
template<...> void | rotateImage (SplineImageView< ORDER, T > const &src, DestIterator id, DestAccessor dest, double angleInDegree, TinyVector< double, 2 > const &center)
| Rotate image by an arbitrary angle.
template<...> void | rotateImage (SrcIterator is, SrcIterator end, SrcAccessor as, DestIterator id, DestAccessor ad, int rotation)
| Rotate image by a multiple of 90 degrees.
template<...> void | reflectImage (SrcIterator is, SrcIterator end, SrcAccessor as, DestIterator id, DestAccessor ad, Reflect reflect)
| Reflect image horizontally or vertically.
template<...> void | transposeImage (SrcIterator is, SrcIterator end, SrcAccessor as, DestIterator id, DestAccessor ad, Transpose transpose)
| Transpose an image over the major or minor diagonal.
template<...> void | resampleImage (SrcIterator is, SrcIterator iend, SrcAccessor sa, DestIterator id, DestAccessor ad, double factor)
| Resample image by a given factor.
template<...> void | resizeImageNoInterpolation (SrcIterator is, SrcIterator iend, SrcAccessor sa, DestIterator id, DestIterator idend, DestAccessor da)
| Resize image by repeating the nearest pixel values.
template<...> void | resizeImageLinearInterpolation (SrcIterator is, SrcIterator iend, SrcAccessor sa, DestIterator id, DestIterator idend, DestAccessor da)
| Resize image using linear interpolation.
template<...> void | resizeImageSplineInterpolation (SrcIterator src_iter, SrcIterator src_iter_end, SrcAccessor src_acc, DestIterator dest_iter, DestIterator dest_iter_end, DestAccessor dest_acc, SPLINE const &spline)
| Resize image using B-spline interpolation.
template<...> void | resizeImageCatmullRomInterpolation (SrcIterator src_iter, SrcIterator src_iter_end, SrcAccessor src_acc, DestIterator dest_iter, DestIterator dest_iter_end, DestAccessor dest_acc)
| Resize image using the Catmull/Rom interpolation function.
template<...> void | resizeImageCoscotInterpolation (SrcIterator src_iter, SrcIterator src_iter_end, SrcAccessor src_acc, DestIterator dest_iter, DestIterator dest_iter_end, DestAccessor dest_acc)
| Resize image using the Coscot interpolation function.

## Detailed Description

Zoom up and down by repeating pixels, or using various interpolation schemes.

See also: resamplingConvolveImage(), resampleImage()

#include "vigra/stdimagefunctions.hxx"
or
#include "vigra/resizeimage.hxx"

## Function Documentation

void reflectImage (...)

| Reflect image horizontally or vertically. The reflection direction refers to the reflection axis, i.e. horizontal reflection turns the image upside down, vertical reflection changes left for right. The directions are selected by the enum values `vigra::horizontal` and `vigra::vertical`. The two directions can also be "or"ed together to perform both reflections simultaneously (see example below) -- this is the same as a 180 degree rotation. Declarations: pass arguments explicitly:
        namespace vigra {
            template <class SrcIterator, class SrcAccessor,
                      class DestIterator, class DestAccessor>
            void
            reflectImage(SrcIterator is, SrcIterator end, SrcAccessor as,
                         DestIterator id, DestAccessor ad, Reflect axis);
        }
use argument objects in conjunction with Argument Object Factories:
        namespace vigra {
            template <class SrcImageIterator, class SrcAccessor,
                  class DestImageIterator, class DestAccessor>
            inline void
            reflectImage(triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
                         pair<DestImageIterator, DestAccessor> dest, Reflect axis);
        }
Usage: #include "vigra/basicgeometry.hxx" Namespace: vigra
        Image dest(src.width(), src.height());

        vigra::reflectImage(srcImageRange(src), destImage(dest), vigra::horizontal | vigra::vertical);
Required Interface:
        SrcImageIterator src_upperleft, src_lowerright;
        DestImageIterator dest_upperleft;

        SrcAccessor src_accessor;

        dest_accessor.set(src_accessor(src_upperleft), dest_upperleft);
Preconditions:
        src_lowerright.x - src_upperleft.x > 1
        src_lowerright.y - src_upperleft.y > 1

void resampleImage (...)

| Resample image by a given factor. This algorithm is very fast and does not require any arithmetic on the pixel types. The input image must have a size of at least 2x2. Destiniation pixels are directly copied from the appropriate source pixels. The size of the result image is the product of `factor` and the original size, where we round up if `factor < 1.0` and down otherwise. This size calculation is the main difference to the convention used in the similar function resizeImageNoInterpolation(): there, the result size is calculated as `n*(old_width-1)+1` and `n*(old_height-1)+1`. This is because resizeImageNoInterpolation() does not replicate the last pixel in every row/column in order to make it compatible with the other functions of the `resizeImage...` family. It should also be noted that resampleImage() is implemented so that an enlargement followed by the corresponding shrinking reproduces the original image. The function uses accessors. Declarations: pass arguments explicitly:
        namespace vigra {
            template <class SrcIterator, class SrcAccessor,
                      class DestIterator, class DestAccessor>
            void
            resampleImage(SrcIterator is, SrcIterator iend, SrcAccessor sa,
                          DestIterator id, DestAccessor ad, double factor);
        }
use argument objects in conjunction with Argument Object Factories:
        namespace vigra {
            template <class SrcImageIterator, class SrcAccessor,
                  class DestImageIterator, class DestAccessor>
            inline void
            resampleImage(triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
                          pair<DestImageIterator, DestAccessor> dest, double factor);
        }
Usage: #include "vigra/basicgeometry.hxx" Namespace: vigra
        double factor = 2.0;
        Image dest((int)(factor*src.width()), (int)(factor*src.height()));

        vigra::resampleImage(srcImageRange(src), destImage(dest), factor);
Required Interface:
        SrcImageIterator src_upperleft, src_lowerright;
        DestImageIterator dest_upperleft;

        SrcAccessor src_accessor;

        dest_accessor.set(src_accessor(src_upperleft), dest_upperleft);
Preconditions:
        src_lowerright.x - src_upperleft.x > 1
        src_lowerright.y - src_upperleft.y > 1

void resizeImageCatmullRomInterpolation (...)

| Resize image using the Catmull/Rom interpolation function. The function calls like resizeImageSplineInterpolation() with vigra::CatmullRomSpline as an interpolation kernel. The interpolated function has one continuous derivative. (See resizeImageSplineInterpolation() for more documentation) Declarations: pass arguments explicitly:
        namespace vigra {
            template <class SrcIterator, class SrcAccessor,
                      class DestIterator, class DestAccessor>
            void
            resizeImageCatmullRomInterpolation(SrcIterator src_iter, SrcIterator src_iter_end, SrcAccessor src_acc,
                                  DestIterator dest_iter, DestIterator dest_iter_end, DestAccessor dest_acc);
        }
use argument objects in conjunction with Argument Object Factories:
        namespace vigra {
            template <class SrcIterator, class SrcAccessor,
                      class DestIterator, class DestAccessor>
            void
            resizeImageCatmullRomInterpolation(triple<SrcIterator, SrcIterator, SrcAccessor> src,
                                  triple<DestIterator, DestIterator, DestAccessor> dest);
        }
#include "vigra/resizeimage.hxx" Namespace: vigra

void resizeImageCoscotInterpolation (...)

| Resize image using the Coscot interpolation function. The function calls resizeImageSplineInterpolation() with vigra::CoscotFunction as an interpolation kernel. The interpolated function has one continuous derivative. (See resizeImageSplineInterpolation() for more documentation) Declarations: pass arguments explicitly:
        namespace vigra {
            template <class SrcIterator, class SrcAccessor,
                      class DestIterator, class DestAccessor>
            void
            resizeImageCoscotInterpolation(SrcIterator src_iter, SrcIterator src_iter_end, SrcAccessor src_acc,
                                  DestIterator dest_iter, DestIterator dest_iter_end, DestAccessor dest_acc);
        }
use argument objects in conjunction with Argument Object Factories:
        namespace vigra {
            template <class SrcIterator, class SrcAccessor,
                      class DestIterator, class DestAccessor>
            void
            resizeImageCoscotInterpolation(triple<SrcIterator, SrcIterator, SrcAccessor> src,
                                  triple<DestIterator, DestIterator, DestAccessor> dest);
        }
#include "vigra/resizeimage.hxx" Namespace: vigra

void resizeImageLinearInterpolation (...)

| Resize image using linear interpolation. The function uses the standard separable bilinear interpolation algorithm to obtain a good compromize between quality and speed. The range must of both the input and output images (resp. regions) must be given. Both images must have a size of at least 2x2. The scaling factors are then calculated accordingly. If the source image is larger than the destination, it is smoothed (band limited) using a recursive exponential filter. The source value_type (SrcAccessor::value_type) must be a linear space, i.e. it must support addition, multiplication with a scalar real number and NumericTraits. The function uses accessors. Declarations: pass arguments explicitly:
        namespace vigra {
            template <class SrcImageIterator, class SrcAccessor,
                  class DestImageIterator, class DestAccessor>
            void
            resizeImageLinearInterpolation(
                  SrcImageIterator is, SrcImageIterator iend, SrcAccessor sa,
              DestImageIterator id, DestImageIterator idend, DestAccessor da)
        }
use argument objects in conjunction with Argument Object Factories:
        namespace vigra {
            template <class SrcImageIterator, class SrcAccessor,
                  class DestImageIterator, class DestAccessor>
            void
            resizeImageLinearInterpolation(
                  triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
              triple<DestImageIterator, DestImageIterator, DestAccessor> dest)
        }
Usage: #include "vigra/resizeimage.hxx" Namespace: vigra
        vigra::resizeImageLinearInterpolation(
                   src.upperLeft(), src.lowerRight(), src.accessor(),
                   dest.upperLeft(), dest.lowerRight(), dest.accessor());
Required Interface:
        SrcImageIterator src_upperleft, src_lowerright;
        DestImageIterator dest_upperleft, src_lowerright;

        SrcAccessor src_accessor;
        DestAccessor dest_accessor;

        NumericTraits<SrcAccessor::value_type>::RealPromote
                                 u = src_accessor(src_upperleft),
                     v = src_accessor(src_upperleft, 1);
        double d;

        u = d * v;
        u = u + v;

        dest_accessor.set(
            NumericTraits<DestAccessor::value_type>::fromRealPromote(u),
        dest_upperleft);
Preconditions:
        src_lowerright.x - src_upperleft.x > 1
        src_lowerright.y - src_upperleft.y > 1
        dest_lowerright.x - dest_upperleft.x > 1
        dest_lowerright.y - dest_upperleft.y > 1

void resizeImageNoInterpolation (...)

| Resize image by repeating the nearest pixel values. This algorithm is very fast and does not require any arithmetic on the pixel types. The range of both the input and output images (resp. regions) must be given. Both images must have a size of at least 2x2 pixels. The scaling factors are then calculated accordingly. Destination pixels are directly copied from the appropriate source pixels. The function uses accessors. Declarations: pass arguments explicitly:
        namespace vigra {
            template <class SrcImageIterator, class SrcAccessor,
                  class DestImageIterator, class DestAccessor>
            void
            resizeImageNoInterpolation(
                  SrcImageIterator is, SrcImageIterator iend, SrcAccessor sa,
              DestImageIterator id, DestImageIterator idend, DestAccessor da)
        }
use argument objects in conjunction with Argument Object Factories:
        namespace vigra {
            template <class SrcImageIterator, class SrcAccessor,
                  class DestImageIterator, class DestAccessor>
            void
            resizeImageNoInterpolation(
                  triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
              triple<DestImageIterator, DestImageIterator, DestAccessor> dest)
        }
Usage: #include "vigra/resizeimage.hxx" Namespace: vigra
        vigra::resizeImageNoInterpolation(
                   src.upperLeft(), src.lowerRight(), src.accessor(),
                   dest.upperLeft(), dest.lowerRight(), dest.accessor());
Required Interface:
        SrcImageIterator src_upperleft, src_lowerright;
        DestImageIterator dest_upperleft, src_lowerright;

        SrcAccessor src_accessor;
        DestAccessor dest_accessor;

        dest_accessor.set(src_accessor(src_upperleft), dest_upperleft);
Preconditions:
        src_lowerright.x - src_upperleft.x > 1
        src_lowerright.y - src_upperleft.y > 1
        dest_lowerright.x - dest_upperleft.x > 1
        dest_lowerright.y - dest_upperleft.y > 1

void resizeImageSplineInterpolation (...)

| Resize image using B-spline interpolation. The function implements separable spline interpolation algorithm described in M. Unser, A. Aldroubi, M. Eden, "B-Spline Signal Processing" IEEE Transactions on Signal Processing, vol. 41, no. 2, pp. 821-833 (part I), pp. 834-848 (part II), 1993. to obtain optimal interpolation quality and speed. You may pass the funcion a spline of arbitrary order (e.g. `BSpline<ORDER, double>` or `CatmullRomSpline<double>`). The default is a third order spline which gives a twice continuously differentiable interpolant. The implementation ensures that image values are interpolated rather than smoothed by first calling a recursive (sharpening) prefilter as described in the above paper. Then the actual interpolation is done using resamplingConvolveLine(). The range of both the input and output images (resp. regions) must be given. The input image must have a size of at least 4x4, the destination of at least 2x2. The scaling factors are then calculated accordingly. If the source image is larger than the destination, it is smoothed (band limited) using a recursive exponential filter. The source value_type (SrcAccessor::value_type) must be a linear algebra, i.e. it must support addition, subtraction, and multiplication (+, -, *), multiplication with a scalar real number and NumericTraits. The function uses accessors. Declarations: pass arguments explicitly:
        namespace vigra {
            template <class SrcImageIterator, class SrcAccessor,
                  class DestImageIterator, class DestAccessor,
                  class SPLINE>
            void
            resizeImageSplineInterpolation(
                  SrcImageIterator is, SrcImageIterator iend, SrcAccessor sa,
              DestImageIterator id, DestImageIterator idend, DestAccessor da,
              SPLINE spline = BSpline<3, double>())
        }
use argument objects in conjunction with Argument Object Factories:
        namespace vigra {
            template <class SrcImageIterator, class SrcAccessor,
                  class DestImageIterator, class DestAccessor,
                  class SPLINE>
            void
            resizeImageSplineInterpolation(
                  triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
                  triple<DestImageIterator, DestImageIterator, DestAccessor> dest,
                  SPLINE spline = BSpline<3, double>())
        }
Usage: #include "vigra/resizeimage.hxx" Namespace: vigra
        vigra::resizeImageSplineInterpolation(
                   src.upperLeft(), src.lowerRight(), src.accessor(),
                   dest.upperLeft(), dest.lowerRight(), dest.accessor());
Required Interface:
        SrcImageIterator src_upperleft, src_lowerright;
        DestImageIterator dest_upperleft, src_lowerright;

        SrcAccessor src_accessor;
        DestAccessor dest_accessor;

        NumericTraits<SrcAccessor::value_type>::RealPromote
                                 u = src_accessor(src_upperleft),
                     v = src_accessor(src_upperleft, 1);
        double d;

        u = d * v;
        u = u + v;
        u = u - v;
        u = u * v;
        u += v;
        u -= v;

        dest_accessor.set(
            NumericTraits<DestAccessor::value_type>::fromRealPromote(u),
        dest_upperleft);
Preconditions:
        src_lowerright.x - src_upperleft.x > 3
        src_lowerright.y - src_upperleft.y > 3
        dest_lowerright.x - dest_upperleft.x > 1
        dest_lowerright.y - dest_upperleft.y > 1

void rotateImage (...)

| Rotate image by a multiple of 90 degrees. This algorithm just copies the pixels in the appropriate new order. It expects the destination image to have the correct shape for the desired rotation. Declarations: pass arguments explicitly:
        namespace vigra {
            template <class SrcIterator, class SrcAccessor,
                      class DestIterator, class DestAccessor>
            void
            rotateImage(SrcIterator is, SrcIterator end, SrcAccessor as,
                        DestIterator id, DestAccessor ad, int rotation);
        }
use argument objects in conjunction with Argument Object Factories:
        namespace vigra {
            template <class SrcImageIterator, class SrcAccessor,
                  class DestImageIterator, class DestAccessor>
            inline void
            rotateImage(triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
                        pair<DestImageIterator, DestAccessor> dest, int rotation);
        }
Usage: #include "vigra/basicgeometry.hxx" Namespace: vigra
        Image dest(src.height(), src.width()); // note that width and height are exchanged

        vigra::rotateImage(srcImageRange(src), destImage(dest), 90);
Required Interface:
        SrcImageIterator src_upperleft, src_lowerright;
        DestImageIterator dest_upperleft;

        SrcAccessor src_accessor;

        dest_accessor.set(src_accessor(src_upperleft), dest_upperleft);
Preconditions:
        src_lowerright.x - src_upperleft.x > 1
        src_lowerright.y - src_upperleft.y > 1

void rotateImage (...)

| Rotate image by an arbitrary angle. The algorithm performs a rotation about the given center point (the image center by default) using the given SplineImageView for interpolation. The destination imae must have the same size as the source SplineImageView. The rotation is counter-clockwise, and the angle must be given in degrees. Declarations: pass arguments explicitly:
        namespace vigra {
            // rotate about given center point
            template <int ORDER, class T,
                      class DestIterator, class DestAccessor>
            void rotateImage(SplineImageView<ORDER, T> const & src,
                             DestIterator id, DestAccessor dest,
                             double angleInDegree, TinyVector<double, 2> const & center);

            // rotate about image center
            template <int ORDER, class T,
                      class DestIterator, class DestAccessor>
            void
            rotateImage(SplineImageView<ORDER, T> const & src,
                        DestIterator id, DestAccessor dest,
                        double angleInDegree)
        }
use argument objects in conjunction with Argument Object Factories:
        namespace vigra {
            // rotate about given center point
            template <int ORDER, class T,
                      class DestIterator, class DestAccessor>
            void
            rotateImage(SplineImageView<ORDER, T> const & src,
                        pair<DestImageIterator, DestAccessor> dest,
                        double angleInDegree, TinyVector<double, 2> const & center);

            // rotate about image center
            template <int ORDER, class T,
                      class DestIterator, class DestAccessor>
            void
            rotateImage(SplineImageView<ORDER, T> const & src,
                        pair<DestImageIterator, DestAccessor> dest,
                        double angleInDegree);
        }
Usage: #include "vigra/affinegeometry.hxx" Namespace: vigra
        Image src(width, height);
        vigra::SplineImageView<3, Image::value_type> spline(srcImageRange(src));

        Image dest(width, height);

        vigra::rotateImage(spline, destImage(dest), 38.5);
Required Interface:
        DestImageIterator dest_upperleft;

        double x = ..., y = ...;

        if (spline.isInside(x,y))
            dest_accessor.set(spline(x, y), dest_upperleft);

void transposeImage (...)

| Transpose an image over the major or minor diagonal. The transposition direction refers to the axis, i.e. major transposition turns the upper right corner into the lower left one, whereas minor transposition changes the upper left corner into the lower right one. The directions are selected by the enum values `vigra::major` and `vigra::minor`. The two directions can also be "or"ed together to perform both reflections simultaneously (see example below) -- this is the same as a 180 degree rotation. Declarations: pass arguments explicitly:
        namespace vigra {
            template <class SrcIterator, class SrcAccessor,
                      class DestIterator, class DestAccessor>
            void
            transposeImage(SrcIterator is, SrcIterator end, SrcAccessor as,
                           DestIterator id, DestAccessor ad, Transpose axis);
        }
use argument objects in conjunction with Argument Object Factories:
        namespace vigra {
            template <class SrcImageIterator, class SrcAccessor,
                  class DestImageIterator, class DestAccessor>
            inline void
            transposeImage(triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
                           pair<DestImageIterator, DestAccessor> dest, Transpose axis);
        }
Usage: #include "vigra/basicgeometry.hxx" Namespace: vigra
        Image dest(src.width(), src.height());

        vigra::transposeImage(srcImageRange(src), destImage(dest), vigra::major | vigra::minor);
Required Interface:
        SrcImageIterator src_upperleft, src_lowerright;
        DestImageIterator dest_upperleft;

        SrcAccessor src_accessor;

        dest_accessor.set(src_accessor(src_upperleft), dest_upperleft);
Preconditions:
        src_lowerright.x - src_upperleft.x > 1
        src_lowerright.y - src_upperleft.y > 1

© Ullrich Köthe (koethe@informatik.uni-hamburg.de) Cognitive Systems Group, University of Hamburg, Germany | html generated using doxygen and Python VIGRA 1.5.0 (7 Dec 2006)