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

| SplineImageView< ORDER, VALUETYPE > Class Template Reference |

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

`#include <vigra/splineimageview.hxx>`

## Public Types

typedef TinyVector< double, 2 > | difference_type
typedef BasicImage< InternalValue > | InternalImage
typedef Size2D | size_type
typedef NormTraits< VALUETYPE >::SquaredNormType | SquaredNormType
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
SquaredNormType | g2 (difference_type const &d) const
SquaredNormType | g2 (double x, double y) const
SquaredNormType | g2x (difference_type const &d) const
SquaredNormType | g2x (double x, double y) const
SquaredNormType | g2xx (difference_type const &d) const
SquaredNormType | g2xx (double x, double y) const
SquaredNormType | g2xy (difference_type const &d) const
SquaredNormType | g2xy (double x, double y) const
SquaredNormType | g2y (difference_type const &d) const
SquaredNormType | g2y (double x, double y) const
SquaredNormType | g2yy (difference_type const &d) const
SquaredNormType | g2yy (double x, double y) const
unsigned int | height () const
const InternalImage & | 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) const
value_type | operator() (difference_type const &d, unsigned int dx, unsigned int dy) const
value_type | operator() (double x, double y) const
value_type | operator() (double x, double y, unsigned int dx, unsigned int dy) const
bool | sameFacet (double x0, double y0, double x1, double y1) const
TinyVector< unsigned int, 2 > | shape () const
size_type | size () const
template<class U , class S >
| SplineImageView (MultiArrayView< 2, U, S > const &s, bool skipPrefiltering=false)
template<class SrcIterator , class SrcAccessor >
| SplineImageView (SrcIterator is, SrcIterator iend, SrcAccessor sa, bool skipPrefiltering=false)
template<class SrcIterator , class SrcAccessor >
| SplineImageView (triple< SrcIterator, SrcIterator, SrcAccessor > s, 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

## ◆ value_type

typedef VALUETYPE value_type

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

## ◆ SquaredNormType

typedef NormTraits<VALUETYPE>::SquaredNormType SquaredNormType

The view's squared norm type (return type of g2() etc.).

## ◆ size_type

typedef Size2D size_type

The view's size type.

## ◆ difference_type

typedef TinyVector<double, 2> difference_type

The view's difference type.

## ◆ InternalImage

typedef BasicImage<InternalValue> InternalImage

The type of the internal image holding the spline coefficients.

## Member Enumeration Documentation

## ◆ StaticOrder

enum StaticOrder

The order of the spline used.

## Constructor & Destructor Documentation

## ◆ SplineImageView() [1/3]

SplineImageView | ( | MultiArrayView< 2, U, S > const & | s,
|  | bool | skipPrefiltering = `false`
| ) |  |

Construct SplineImageView for a 2D MultiArrayView.

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.

## ◆ SplineImageView() [2/3]

SplineImageView | ( | SrcIterator | is,
|  | SrcIterator | iend,
|  | SrcAccessor | sa,
|  | bool | skipPrefiltering = `false`
| ) |  |

Construct SplineImageView for an image given by Image Iterators and Data Accessors.

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.

## ◆ SplineImageView() [3/3]

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

Construct SplineImageView for an image given by Argument Object Factories.

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

## ◆ operator()() [1/4]

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.

## ◆ operator()() [2/4]

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.

## ◆ dx() [1/2]

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)`.

## ◆ dy() [1/2]

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)`.

## ◆ dxx() [1/2]

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)`.

## ◆ dxy() [1/2]

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)`.

## ◆ dyy() [1/2]

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)`.

## ◆ dx3() [1/2]

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)`.

## ◆ dy3() [1/2]

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)`.

## ◆ dxxy() [1/2]

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)`.

## ◆ dxyy() [1/2]

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)`.

## ◆ operator()() [3/4]

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

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

## ◆ operator()() [4/4]

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)`.

## ◆ dx() [2/2]

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])`.

## ◆ dy() [2/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])`.

## ◆ dxx() [2/2]

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])`.

## ◆ dxy() [2/2]

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])`.

## ◆ dyy() [2/2]

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])`.

## ◆ dx3() [2/2]

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])`.

## ◆ dy3() [2/2]

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])`.

## ◆ dxxy() [2/2]

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])`.

## ◆ dxyy() [2/2]

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])`.

## ◆ g2() [1/2]

SplineImageView< ORDER, VALUETYPE >::SquaredNormType g2 | ( | double | x,
|  | double | y
| ) |  | const

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

## ◆ g2x() [1/2]

SplineImageView< ORDER, VALUETYPE >::SquaredNormType g2x | ( | double | x,
|  | double | y
| ) |  | const

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

## ◆ g2y() [1/2]

SplineImageView< ORDER, VALUETYPE >::SquaredNormType g2y | ( | double | x,
|  | double | y
| ) |  | const

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

## ◆ g2xx() [1/2]

SplineImageView< ORDER, VALUETYPE >::SquaredNormType g2xx | ( | double | x,
|  | double | y
| ) |  | const

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

## ◆ g2xy() [1/2]

SplineImageView< ORDER, VALUETYPE >::SquaredNormType g2xy | ( | double | x,
|  | double | y
| ) |  | const

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

## ◆ g2yy() [1/2]

SplineImageView< ORDER, VALUETYPE >::SquaredNormType g2yy | ( | double | x,
|  | double | y
| ) |  | const

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

## ◆ g2() [2/2]

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

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

## ◆ g2x() [2/2]

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

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

## ◆ g2y() [2/2]

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

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

## ◆ g2xx() [2/2]

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

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

## ◆ g2xy() [2/2]

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

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

## ◆ g2yy() [2/2]

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

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

## ◆ width()

unsigned int width | ( |  | ) | const

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

## ◆ height()

unsigned int height | ( |  | ) | const

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

## ◆ size()

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.

## ◆ shape()

TinyVector<unsigned int, 2> shape | ( |  | ) | const

The shape of the image. Same as size(), except for the return type.

## ◆ image()

const InternalImage& image | ( |  | ) | const

The internal image holding the spline coefficients.

## ◆ coefficientArray()

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` must have 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);

## ◆ isInsideX()

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

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

## ◆ isInsideY()

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

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

## ◆ isInside()

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`.

## ◆ isValid()

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 reflective 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`.

## ◆ sameFacet()

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)`.

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

- vigra/splineimageview.hxx

vigra::UInt32
detail::SelectIntegerType< 32, detail::UnsignedIntTypes >::type UInt32
32-bit unsigned int
Definition: sized_int.hxx:183
vigra::SplineImageView::dx
value_type dx(double x, double y) const
Definition: splineimageview.hxx:216
vigra::floor
int floor(FixedPoint< IntBits, FracBits > v)
rounding down.
Definition: fixedpoint.hxx:667
vigra::BImage
BasicImage< UInt8 > BImage
Definition: stdimage.hxx:62
vigra::abs
FFTWComplex< R >::NormType abs(const FFTWComplex< R > &a)
absolute value (= magnitude)
Definition: fftw3.hxx:1002
vigra::SplineImageView::dy
value_type dy(double x, double y) const
Definition: splineimageview.hxx:222

© 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.11.1