VIGRA - VIGRA: SplineImageView Class Template Reference

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

| SplineImageView |

Create a continuous view onto a discrete image using splines. More...

`#include <vigra/splineimageview.hxx>`

List of all members.

## Public Types
typedef TinyVector< double, 2 > | difference_type
typedef BasicImage< InternalValue > | InternalImage
typedef Size2D | size_type
enum | StaticOrder
typedef VALUETYPE | value_type
## Public Member Functions
template<class Array>
void | coefficientArray (double x, double y, Array &res) const
value_type | dx (difference_type const &d) const
value_type | dx (double x, double y) const
value_type | dx3 (difference_type const &d) const
value_type | dx3 (double x, double y) const
value_type | dxx (difference_type const &d) const
value_type | dxx (double x, double y) const
value_type | dxxy (difference_type const &d) const
value_type | dxxy (double x, double y) const
value_type | dxy (difference_type const &d) const
value_type | dxy (double x, double y) const
value_type | dxyy (difference_type const &d) const
value_type | dxyy (double x, double y) const
value_type | dy (difference_type const &d) const
value_type | dy (double x, double y) const
value_type | dy3 (difference_type const &d) const
value_type | dy3 (double x, double y) const
value_type | dyy (difference_type const &d) const
value_type | dyy (double x, double y) const
value_type | g2 (difference_type const &d) const
value_type | g2 (double x, double y) const
value_type | g2x (difference_type const &d) const
value_type | g2x (double x, double y) const
value_type | g2xx (difference_type const &d) const
value_type | g2xx (double x, double y) const
value_type | g2xy (difference_type const &d) const
value_type | g2xy (double x, double y) const
value_type | g2y (difference_type const &d) const
value_type | g2y (double x, double y) const
value_type | g2yy (difference_type const &d) const
value_type | g2yy (double x, double y) const
unsigned int | height () const
InternalImage const & | image () const
bool | isInside (double x, double y) const
bool | isInsideX (double x) const
bool | isInsideY (double y) const
bool | isValid (double x, double y) const
value_type | operator() (difference_type const &d, unsigned int dx, unsigned int dy) const
value_type | operator() (difference_type const &d) const
value_type | operator() (double x, double y, unsigned int dx, unsigned int dy) const
value_type | operator() (double x, double y) const
bool | sameFacet (double x0, double y0, double x1, double y1) const
size_type | size () const
template<class SrcIterator, class SrcAccessor>
| SplineImageView (triple< SrcIterator, SrcIterator, SrcAccessor > s, bool skipPrefiltering=false)
template<class SrcIterator, class SrcAccessor>
| SplineImageView (SrcIterator is, SrcIterator iend, SrcAccessor sa, bool skipPrefiltering=false)
unsigned int | width () const

## Detailed Description

### template<int ORDER, class VALUETYPE>
class vigra::SplineImageView< ORDER, VALUETYPE >

Create a continuous view onto a discrete image using splines.

This class is very useful if image values or derivatives at arbitrary real-valued coordinates are needed. Access at such coordinates is implemented by interpolating the given discrete image values with a spline of the specified `ORDER`. Continuous derivatives are available up to degree `ORDER-1`. If the requested coordinates are near the image border, reflective boundary conditions are applied. In principle, this class can also be used for image resizing, but here the functions from the `resize...` family are more efficient, since they exploit the regularity of the sampling grid.

The `SplineImageView` template is explicitly specialized to make it as efficient as possible. In particular, unnecessary copying of the image is avoided when the iterators passed in the constructor originate from a vigra::BasicImage. In addition, these specializations provide function `unchecked(...)` that do not perform bounds checking. If the original image is not a variant of vigra::BasicImage, one can customize the internal representation by using vigra::SplineImageView0 or vigra::SplineImageView1.

Usage:

#include <vigra/splineimageview.hxx>
Namespace: vigra

        BImage img(w,h);
        ... // fill img

        // construct spline view for quadratic interpolation
        SplineImageView<2, double> spi2(srcImageRange(img));

        double x = ..., y = ...;
        double v2 = spi2(x, y);

        // construct spline view for linear interpolation
        SplineImageView<1, UInt32> spi1(srcImageRange(img));

        UInt32 v1 = spi1(x, y);

        FixedPoint<16, 15> fx(...), fy(...);
        UInt32 vf = spi1.unchecked(fx, fy); // caller is sure that (fx, fy) are valid coordinates

## Member Typedef Documentation

typedef TinyVector<double, 2> difference_type

The view's difference type.

typedef BasicImage<InternalValue> InternalImage

The type of the internal image holding the spline coefficients.

typedef Size2D size_type

The view's size type.

typedef VALUETYPE value_type

The view's value type (return type of access and derivative functions).

## Member Enumeration Documentation

enum StaticOrder

The order of the spline used.

## Constructor & Destructor Documentation

template<class SrcIterator, class SrcAccessor>
SplineImageView | ( | SrcIterator | is,
|  | SrcIterator | iend,
|  | SrcAccessor | sa,
|  | bool | skipPrefiltering = `false` |
| ) |  |  |

Construct SplineImageView for the given image.

If `skipPrefiltering = true` (default: `false`), the recursive prefilter of the cardinal spline function is not applied, resulting in an approximating (smoothing) rather than interpolating spline. This is especially useful if customized prefilters are to be applied.

template<class SrcIterator, class SrcAccessor>
SplineImageView | ( | triple< SrcIterator, SrcIterator, SrcAccessor > | s,
|  | bool | skipPrefiltering = `false` |
| ) |  |  |

Construct SplineImageView for the given image.

If `skipPrefiltering = true` (default: `false`), the recursive prefilter of the cardinal spline function is not applied, resulting in an approximating (smoothing) rather than interpolating spline. This is especially useful if customized prefilters are to be applied.

## Member Function Documentation

template<class Array>
void coefficientArray | ( | double | x,
|  | double | y,
|  | Array & | res |
| ) |  |  | const

Get the array of polynomial coefficients for the facet containing the point `(x, y)`. The array `res` will be resized to dimension `(ORDER+1)x(ORDER+1)`. From these coefficients, the value of the interpolated function can be calculated by the following algorithm

                SplineImageView<ORDER, float> view(...);
                double x = ..., y = ...;
                double dx, dy;

                // calculate the local facet coordinates of x and y
                if(ORDER % 2)
                {
                    // odd order => facet coordinates between 0 and 1
                    dx = x - floor(x);
                    dy = y - floor(y);
                }
                else
                {
                    // even order => facet coordinates between -0.5 and 0.5
                    dx = x - floor(x + 0.5);
                    dy = y - floor(y + 0.5);
                }

                BasicImage<float> coefficients;
                view.coefficientArray(x, y, coefficients);

                float f_x_y = 0.0;
                for(int ny = 0; ny < ORDER + 1; ++ny)
                    for(int nx = 0; nx < ORDER + 1; ++nx)
                        f_x_y += pow(dx, nx) * pow(dy, ny) * coefficients(nx, ny);

                assert(abs(f_x_y - view(x, y)) < 1e-6);

value_type dx | ( | difference_type const & | d | ) | const

Access 1st derivative in x-direction at real-valued coordinate `d`. Equivalent to `splineView.dx(d[0], d[1])`.

value_type dx | ( | double | x,
|  | double | y |
| ) |  |  | const

Access 1st derivative in x-direction at real-valued coordinate `(x, y)`. Equivalent to `splineView(x, y, 1, 0)`.

value_type dx3 | ( | difference_type const & | d | ) | const

Access 3rd derivative in x-direction at real-valued coordinate `d`. Equivalent to `splineView.dx3(d[0], d[1])`.

value_type dx3 | ( | double | x,
|  | double | y |
| ) |  |  | const

Access 3rd derivative in x-direction at real-valued coordinate `(x, y)`. Equivalent to `splineView(x, y, 3, 0)`.

value_type dxx | ( | difference_type const & | d | ) | const

Access 2nd derivative in x-direction at real-valued coordinate `d`. Equivalent to `splineView.dxx(d[0], d[1])`.

value_type dxx | ( | double | x,
|  | double | y |
| ) |  |  | const

Access 2nd derivative in x-direction at real-valued coordinate `(x, y)`. Equivalent to `splineView(x, y, 2, 0)`.

value_type dxxy | ( | difference_type const & | d | ) | const

Access mixed 3rd derivative dxxy at real-valued coordinate `d`. Equivalent to `splineView.dxxy(d[0], d[1])`.

value_type dxxy | ( | double | x,
|  | double | y |
| ) |  |  | const

Access mixed 3rd derivative dxxy at real-valued coordinate `(x, y)`. Equivalent to `splineView(x, y, 2, 1)`.

value_type dxy | ( | difference_type const & | d | ) | const

Access mixed 2nd derivative at real-valued coordinate `d`. Equivalent to `splineView.dxy(d[0], d[1])`.

value_type dxy | ( | double | x,
|  | double | y |
| ) |  |  | const

Access mixed 2nd derivative at real-valued coordinate `(x, y)`. Equivalent to `splineView(x, y, 1, 1)`.

value_type dxyy | ( | difference_type const & | d | ) | const

Access mixed 3rd derivative dxyy at real-valued coordinate `d`. Equivalent to `splineView.dxyy(d[0], d[1])`.

value_type dxyy | ( | double | x,
|  | double | y |
| ) |  |  | const

Access mixed 3rd derivative dxyy at real-valued coordinate `(x, y)`. Equivalent to `splineView(x, y, 1, 2)`.

value_type dy | ( | difference_type const & | d | ) | const

Access 1st derivative in y-direction at real-valued coordinate `d`. Equivalent to `splineView.dy(d[0], d[1])`.

value_type dy | ( | double | x,
|  | double | y |
| ) |  |  | const

Access 1st derivative in y-direction at real-valued coordinate `(x, y)`. Equivalent to `splineView(x, y, 0, 1)`.

value_type dy3 | ( | difference_type const & | d | ) | const

Access 3rd derivative in y-direction at real-valued coordinate `d`. Equivalent to `splineView.dy3(d[0], d[1])`.

value_type dy3 | ( | double | x,
|  | double | y |
| ) |  |  | const

Access 3rd derivative in y-direction at real-valued coordinate `(x, y)`. Equivalent to `splineView(x, y, 0, 3)`.

value_type dyy | ( | difference_type const & | d | ) | const

Access 2nd derivative in y-direction at real-valued coordinate `d`. Equivalent to `splineView.dyy(d[0], d[1])`.

value_type dyy | ( | double | x,
|  | double | y |
| ) |  |  | const

Access 2nd derivative in y-direction at real-valued coordinate `(x, y)`. Equivalent to `splineView(x, y, 0, 2)`.

value_type g2 | ( | difference_type const & | d | ) | const

Access gradient squared magnitude at real-valued coordinate `d`.

VALUETYPE g2 | ( | double | x,
|  | double | y |
| ) |  |  | const

Access gradient squared magnitude at real-valued coordinate `(x, y)`.

value_type g2x | ( | difference_type const & | d | ) | const

Access 1st derivative in x-direction of gradient squared magnitude at real-valued coordinate `d`.

VALUETYPE g2x | ( | double | x,
|  | double | y |
| ) |  |  | const

Access 1st derivative in x-direction of gradient squared magnitude at real-valued coordinate `(x, y)`.

value_type g2xx | ( | difference_type const & | d | ) | const

Access 2nd derivative in x-direction of gradient squared magnitude at real-valued coordinate `d`.

VALUETYPE g2xx | ( | double | x,
|  | double | y |
| ) |  |  | const

Access 2nd derivative in x-direction of gradient squared magnitude at real-valued coordinate `(x, y)`.

value_type g2xy | ( | difference_type const & | d | ) | const

Access mixed 2nd derivative of gradient squared magnitude at real-valued coordinate `d`.

VALUETYPE g2xy | ( | double | x,
|  | double | y |
| ) |  |  | const

Access mixed 2nd derivative of gradient squared magnitude at real-valued coordinate `(x, y)`.

value_type g2y | ( | difference_type const & | d | ) | const

Access 1st derivative in y-direction of gradient squared magnitude at real-valued coordinate `d`.

VALUETYPE g2y | ( | double | x,
|  | double | y |
| ) |  |  | const

Access 1st derivative in y-direction of gradient squared magnitude at real-valued coordinate `(x, y)`.

value_type g2yy | ( | difference_type const & | d | ) | const

Access 2nd derivative in y-direction of gradient squared magnitude at real-valued coordinate `d`.

VALUETYPE g2yy | ( | double | x,
|  | double | y |
| ) |  |  | const

Access 2nd derivative in y-direction of gradient squared magnitude at real-valued coordinate `(x, y)`.

unsigned int height | ( |  | ) | const

The height of the image. `0 <= y <= height()-1` is required for all access functions.

InternalImage const& image | ( |  | ) | const

The internal image holding the spline coefficients.

bool isInside | ( | double | x,
|  | double | y |
| ) |  |  | const

Check if x and y are in the original image range. Equivalent to `0 <= x <= width()-1` and `0 <= y <= height()-1`.

bool isInsideX | ( | double | x | ) | const

Check if x is in the original image range. Equivalent to `0 <= x <= width()-1`.

bool isInsideY | ( | double | y | ) | const

Check if y is in the original image range. Equivalent to `0 <= y <= height()-1`.

bool isValid | ( | double | x,
|  | double | y |
| ) |  |  | const

Check if x and y are in the valid range. Points outside the original image range are computed by reflcective boundary conditions, but only within the first reflection. Equivalent to `-width() + ORDER/2 + 2 < x < 2*width() - ORDER/2 - 2` and `-height() + ORDER/2 + 2 < y < 2*height() - ORDER/2 - 2`.

value_type operator() | ( | difference_type const & | d,
|  | unsigned int | dx,
|  | unsigned int | dy |
| ) |  |  | const

Access derivative of order `(dx, dy)` at real-valued coordinate `d`. Equivalent to `splineView(d[0], d[1], dx, dy)`.

value_type operator() | ( | difference_type const & | d | ) | const

Access interpolated function at real-valued coordinate `d`. Equivalent to `splineView(d[0], d[1])`.

VALUETYPE operator() | ( | double | x,
|  | double | y,
|  | unsigned int | dx,
|  | unsigned int | dy |
| ) |  |  | const

Access derivative of order `(dx, dy)` at real-valued coordinate `(x, y)`. If `(x, y)` is near the image border or outside the image, the value is calculated with reflective boundary conditions. An exception is thrown if the coordinate is outside the first reflection.

VALUETYPE operator() | ( | double | x,
|  | double | y |
| ) |  |  | const

Access interpolated function at real-valued coordinate `(x, y)`. If `(x, y)` is near the image border or outside the image, the value is calculated with reflective boundary conditions. An exception is thrown if the coordinate is outside the first reflection.

bool sameFacet | ( | double | x0,
|  | double | y0,
|  | double | x1,
|  | double | y1 |
| ) |  |  | const

Check whether the points `(x0, y0)` and `(x1, y1)` are in the same spline facet. For odd order splines, facets span the range `(floor(x), floor(x)+1) x (floor(y), floor(y)+1)` (i.e. we have integer facet borders), whereas even order splines have facet between half integer values `(floor(x)-0.5, floor(x)+0.5) x (floor(y)-0.5, floor(y)+0.5)`.

size_type size | ( |  | ) | const

The size of the image. `0 <= x <= size().x-1` and `0 <= y <= size().y-1` are required for all access functions.

unsigned int width | ( |  | ) | const

The width of the image. `0 <= x <= width()-1` is required for all access functions.

The documentation for this class was generated from the following file:

- vigra/splineimageview.hxx

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python VIGRA 1.6.0 (13 Aug 2008)