DIPlib Documentation - ©1995-2015 Quantitative Imaging Group, Delft University of Technology.

# Rotation

Interpolation function

## SYNOPSIS

`#include "dip_interpolation.h"`

dip_Error dip_Rotation ( in, out, angle, method, bgval )

## DATA TYPES

binary, integer, float

## FUNCTION

This function rotates an 2-D image `in` over `angle` to `out` using three skews. The function implements the rotation in the mathmetical sense, but note the Y-axis is positive downwards! The rotation is over the centre of the image.

## ARGUMENTS

Data type | Name | Description
`dip_Image` | `in` | Input image
`dip_Image` | `out` | Output image
`dip_float` | `angle (radians)` | Rotation angle
`dipf_Interpolation` | `method` | Interpolation method
`dip_BackgroundValue` | `bgval` | Background value

The `dipf_Interpolation` enumaration consists of the following constants:

Name | Description
`DIP_INTERPOLATION_DEFAULT` | Default method, usually equivalent to `DIP_INTERPOLATION_BSPLINE`
`DIP_INTERPOLATION_BSPLINE` | B-Spline interpolation
`DIP_INTERPOLATION_FOURTH_ORDER_CUBIC` | Forth order cubic interpolation
`DIP_INTERPOLATION_THIRD_ORDER_CUBIC` | Third order cubic interpolation
`DIP_INTERPOLATION_LINEAR` | Linear interpolation
`DIP_INTERPOLATION_ZERO_ORDER_HOLD` | Zero order hold interpolation
`DIP_INTERPOLATION_NEAREST_NEIGHBOUR` | Nearest neighbour interpolation
`DIP_INTERPOLATION_LANCZOS_2` | Lanczos interpolation with a=2
`DIP_INTERPOLATION_LANCZOS_3` | Lanczos interpolation with a=3
`DIP_INTERPOLATION_LANCZOS_4` | Lanczos interpolation with a=4
`DIP_INTERPOLATION_LANCZOS_6` | Lanczos interpolation with a=6
`DIP_INTERPOLATION_LANCZOS_8` | Lanczos interpolation with a=8

All interpolation is performed separably. B-spline interpolation uses all samples on the image line. Cubic interpolation uses a cubic spline kernel (piecewise cubic polynomial), covering 4 (third order) or 6 (fourth order) input samples. Lanczos interpolation uses a sinc function windowed by a wider sinc function, using 2a input samples. Zero order hold and nearest neighbour are the same method, but for the function `Resampling`, zero order hold results in a shift of half a pixel (i.e. the nearest value "to the left" is always used).

The `dip_BackgroundValue` enumaration consists of the following flags:

Name | Description
`DIP_BGV_DEFAULT` | Default: fill with zeros
`DIP_BGV_ZERO` | Fill with zeros
`DIP_BGV_MAX_VALUE` | Fill with maximum value for data type
`DIP_BGV_MIN_VALUE` | Fill with minimum value for data type

## KNOWN BUGS

This function is only implemented for 2D images, for rotating 3D images see `Rotation3d`.

## SEE ALSO

`Skewing`, `Rotation3d`, `Rotation3d_Axis`