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

| Resampling Convolution Filters |
--- | --- | ---

## Functions

template<...> void | resamplingConvolveX (SrcIter sul, SrcIter slr, SrcAcc src, DestIter dul, DestIter dlr, DestAcc dest, Kernel const &kernel, Rational< int > const &samplingRatio, Rational< int > const &offset)
| Apply a resampling filter in the x-direction.
template<...> void | resamplingConvolveY (SrcIter sul, SrcIter slr, SrcAcc src, DestIter dul, DestIter dlr, DestAcc dest, Kernel const &kernel, Rational< int > const &samplingRatio, Rational< int > const &offset)
| Apply a resampling filter in the y-direction.
template<...> void | resamplingConvolveImage (SrcIterator sul, SrcIterator slr, SrcAccessor src, DestIterator dul, DestIterator dlr, DestAccessor dest, KernelX const &kx, Rational< int > const &samplingRatioX, Rational< int > const &offsetX, KernelY const &ky, Rational< int > const &samplingRatioY, Rational< int > const &offsetY)
| Apply two separable resampling filters successively, the first in x-direction, the second in y-direction.

## Detailed Description

These functions implement the convolution operation when the source and target images have different sizes. This is realized by accessing a continous kernel at the appropriate non-integer positions. The technique is, for example, described in D. Schumacher: General Filtered Image Rescaling, in: Graphics Gems III, Academic Press, 1992.

## Function Documentation

void resamplingConvolveImage (...)

Apply two separable resampling filters successively, the first in x-direction, the second in y-direction.

This function is a shorthand for the concatenation of a call to resamplingConvolveX() and resamplingConvolveY() with the given kernels. See there for detailed documentation.

Declarations:

pass arguments explicitly:

        namespace vigra {
            template <class SrcIterator, class SrcAccessor,
                      class DestIterator, class DestAccessor,
                      class KernelX, class KernelY>
            void resamplingConvolveImage(SrcIterator sul,SrcIterator slr, SrcAccessor src,
                               DestIterator dul, DestIterator dlr, DestAccessor dest,
                               KernelX const & kx,
                               Rational<int> const & samplingRatioX, Rational<int> const & offsetX,
                               KernelY const & ky,
                               Rational<int> const & samplingRatioY, Rational<int> const & offsetY);
        }

use argument objects in conjunction with Argument Object Factories:

        namespace vigra {
            template <class SrcIterator, class SrcAccessor,
                      class DestIterator, class DestAccessor,
                      class KernelX, class KernelY>
            void
            resamplingConvolveImage(triple<SrcIterator, SrcIterator, SrcAccessor> src,
                               triple<DestIterator, DestIterator, DestAccessor> dest,
                               KernelX const & kx,
                               Rational<int> const & samplingRatioX, Rational<int> const & offsetX,
                               KernelY const & ky,
                               Rational<int> const & samplingRatioY, Rational<int> const & offsetY);
        }

Usage:

#include "vigra/resampling_convolution.hxx"

        Rational<int> xratio(2), yratio(3), offset(0);

        FImage src(w,h),
               dest(rational_cast<int>(xratio*w), rational_cast<int>(yratio*h));

        float sigma = 2.0;
        Gaussian<float> smooth(sigma);
        ...

        // simpultaneously enlarge and smooth source image
        resamplingConvolveImage(srcImageRange(src), destImageRange(dest),
                                smooth, xratio, offset,
                                smooth, yratio, offset);

void resamplingConvolveX (...)

Apply a resampling filter in the x-direction.

This function implements a convolution operation in x-direction (i.e. applies a 1D filter to every row) where the width of the source and destination images differ. This is typically used to avoid aliasing if the image is scaled down, or to interpolate smoothly if the image is scaled up. The target coordinates are transformed into source coordinates by

        xsource = (xtarget - offset) / samplingRatio

The `samplingRatio` and `offset` must be given as vigra::Rational in order to avoid rounding errors in this transformation. It is required that for all pixels of the target image, `xsource` remains within the range of the source image (i.e. `0 <= xsource <= sourceWidth-1`. Since `xsource` is in general not an integer, the `kernel` must be a functor that can be accessed at arbitrary (`double`) coordinates. It must also provide a member function `radius()` which specifies the support (non-zero interval) of the kernel. VIGRA already provides a number of suitable functors, e.g. vigra::Gaussian, vigra::BSpline vigra::CatmullRomSpline, and vigra::CoscotFunction. The function resizeImageSplineInterpolation() is implemented by means resamplingConvolveX() and resamplingConvolveY().

Declarations:

pass arguments explicitly:

        namespace vigra {
            template <class SrcIter, class SrcAcc,
                      class DestIter, class DestAcc,
                      class Kernel>
            void
            resamplingConvolveX(SrcIter sul, SrcIter slr, SrcAcc src,
                                DestIter dul, DestIter dlr, DestAcc dest,
                                Kernel const & kernel,
                                Rational<int> const & samplingRatio, Rational<int> const & offset);
        }

use argument objects in conjunction with Argument Object Factories:

        namespace vigra {
            template <class SrcIter, class SrcAcc,
                      class DestIter, class DestAcc,
                      class Kernel>
            void
            resamplingConvolveX(triple<SrcIter, SrcIter, SrcAcc> src,
                                triple<DestIter, DestIter, DestAcc> dest,
                                Kernel const & kernel,
                                Rational<int> const & samplingRatio, Rational<int> const & offset);
        }

Usage:

#include "vigra/resampling_convolution.hxx"

        Rational<int> ratio(2), offset(0);

        FImage src(w,h),
               dest(rational_cast<int>(ratio*w), h);

        float sigma = 2.0;
        Gaussian<float> smooth(sigma);
        ...

        // simpultaneously enlarge and smooth source image
        resamplingConvolveX(srcImageRange(src), destImageRange(dest),
                            smooth, ratio, offset);

Required Interface:

        Kernel kernel;
        int kernelRadius = kernel.radius();
        double x = ...;  // must be <= radius()
        double value = kernel(x);

void resamplingConvolveY (...)

Apply a resampling filter in the y-direction.

This function implements a convolution operation in y-direction (i.e. applies a 1D filter to every column) where the height of the source and destination images differ. This is typically used to avoid aliasing if the image is scaled down, or to interpolate smoothly if the image is scaled up. The target coordinates are transformed into source coordinates by

        ysource = (ytarget - offset) / samplingRatio

The `samplingRatio` and `offset` must be given as vigra::Rational in order to avoid rounding errors in this transformation. It is required that for all pixels of the target image, `ysource` remains within the range of the source image (i.e. `0 <= ysource <= sourceHeight-1`. Since `ysource` is in general not an integer, the `kernel` must be a functor that can be accessed at arbitrary (`double`) coordinates. It must also provide a member function `radius()` which specifies the support (non-zero interval) of the kernel. VIGRA already provides a number of suitable functors, e.g. vigra::Gaussian, vigra::BSpline vigra::CatmullRomSpline, and vigra::CoscotFunction. The function resizeImageSplineInterpolation() is implemented by means resamplingConvolveX() and resamplingConvolveY().

Declarations:

pass arguments explicitly:

        namespace vigra {
            template <class SrcIter, class SrcAcc,
                      class DestIter, class DestAcc,
                      class Kernel>
            void
            resamplingConvolveY(SrcIter sul, SrcIter slr, SrcAcc src,
                                DestIter dul, DestIter dlr, DestAcc dest,
                                Kernel const & kernel,
                                Rational<int> const & samplingRatio, Rational<int> const & offset);
        }

use argument objects in conjunction with Argument Object Factories:

        namespace vigra {
            template <class SrcIter, class SrcAcc,
                      class DestIter, class DestAcc,
                      class Kernel>
            void
            resamplingConvolveY(triple<SrcIter, SrcIter, SrcAcc> src,
                                triple<DestIter, DestIter, DestAcc> dest,
                                Kernel const & kernel,
                                Rational<int> const & samplingRatio, Rational<int> const & offset);
        }

Usage:

#include "vigra/resampling_convolution.hxx"

        Rational<int> ratio(2), offset(0);

        FImage src(w,h),
               dest(w, rational_cast<int>(ratio*h));

        float sigma = 2.0;
        Gaussian<float> smooth(sigma);
        ...

        // simpultaneously enlarge and smooth source image
        resamplingConvolveY(srcImageRange(src), destImageRange(dest),
                            smooth, ratio, offset);

Required Interface:

        Kernel kernel;
        int kernelRadius = kernel.radius();
        double y = ...;  // must be <= radius()
        double value = kernel(y);

© 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)