- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

Functions
rotate
Complete List of ArrayFire Functions ArrayFire Functions by Category » Image Processing » | Image transformations

Rotate an input image. More...

## Functions
AFAPI array | rotate (const array &in, const float theta, const bool crop=true, const interpType method=AF_INTERP_NEAREST)
| C++ Interface for rotating an image. More...
AFAPI af_err | af_rotate (af_array *out, const af_array in, const float theta, const bool crop, const af_interp_type method)
| C Interface for rotating an image. More...

## Detailed Description

Rotate an input image.

The angle theta is in radians.

Rotating an input image can be done using either AF_INTERP_NEAREST or AF_INTERP_BILINEAR interpolations. Nearest interpolation will pick the nearest value to the location, whereas bilinear interpolation will do a weighted interpolation for calculate the new size.

This function does not differentiate between images and data. As long as the array is defined, it will rotate any type or size of array.

The crop option allows you to choose whether to resize the image. If crop is set to false, ie. the entire rotated image will be a part of the array and the new array size will be greater than or equal to the input array size. If crop is set to true, then the new array size is same as the input array size and the data that falls outside the boundaries of the array is discarded.

Any location of the rotated array that does not map to a location of the input array is set to 0.

## Function Documentation

AFAPI af_err af_rotate | ( | af_array * | out,
|  | const af_array | in,
|  | const float | theta,
|  | const bool | crop,
|  | const af_interp_type | method
| ) |  |

C Interface for rotating an image.

Parameters

  [out] | out | will contain the image `in` rotated by `theta`
  [in] | in | is input image
  [in] | theta | is the degree (in radians) by which the input is rotated
  [in] | crop | if true the output is cropped original dimensions. If false the output dimensions scale based on `theta`
  [in] | method | is the interpolation type (Nearest by default)

Returns
  AF_SUCCESS if the color transformation is successful, otherwise an appropriate error code is returned.

AFAPI array af::rotate | ( | const array & | in,
|  | const float | theta,
|  | const bool | crop = `true`,
|  | const interpType | method = `AF_INTERP_NEAREST`
| ) |  |

C++ Interface for rotating an image.

Parameters

  [in] | in | is input image
  [in] | theta | is the degree (in radians) by which the input is rotated
  [in] | crop | if true the output is cropped original dimensions. If false the output dimensions scale based on `theta`
  [in] | method | is the interpolation type (Nearest by default)

Returns
  the image rotated by `theta`

Examples:
  image_demo.cpp.