A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
resize
ArrayFire Functions | ArrayFire Functions by Category » Image Processing » Image transformations

## Functions
AFAPI array | resize (const array &in, const dim_t odim0, const dim_t odim1, const interpType method=AF_INTERP_NEAREST)
| C++ Interface for resizing an image to specified dimensions.
AFAPI array | resize (const float scale0, const float scale1, const array &in, const interpType method=AF_INTERP_NEAREST)
| C++ Interface for resizing an image to specified scales.
AFAPI array | resize (const float scale, const array &in, const interpType method=AF_INTERP_NEAREST)
| C++ Interface for resizing an image to specified scale.
AFAPI af_err | af_resize (af_array *out, const af_array in, const dim_t odim0, const dim_t odim1, const af_interp_type method)
| C Interface for resizing an image to specified dimensions.

## Detailed Description

Resize an input image

Resizing an input image can be done using either AF_INTERP_NEAREST, AF_INTERP_BILINEAR or AF_INTERP_LOWER, interpolations. Nearest interpolation will pick the nearest value to the location, bilinear interpolation will do a weighted interpolation for calculate the new size and lower interpolation is similar to the nearest, except it will use the floor function to get the lower neighbor.

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

array in = iota(dim4(5, 3));
af_print(resize(2, in, AF_INTERP_NEAREST));
af_print(resize(2, in, AF_INTERP_BILINEAR));
// in [5 3 1 1]
// 0.0000 5.0000 10.0000
// 1.0000 6.0000 11.0000
// 2.0000 7.0000 12.0000
// 3.0000 8.0000 13.0000
// 4.0000 9.0000 14.0000
//
// resize(2, in, AF_INTERP_NEAREST) [10 6 1 1]
// 0.0000 5.0000 5.0000 10.0000 10.0000 10.0000
// 1.0000 6.0000 6.0000 11.0000 11.0000 11.0000
// 1.0000 6.0000 6.0000 11.0000 11.0000 11.0000
// 2.0000 7.0000 7.0000 12.0000 12.0000 12.0000
// 2.0000 7.0000 7.0000 12.0000 12.0000 12.0000
// 3.0000 8.0000 8.0000 13.0000 13.0000 13.0000
// 3.0000 8.0000 8.0000 13.0000 13.0000 13.0000
// 4.0000 9.0000 9.0000 14.0000 14.0000 14.0000
// 4.0000 9.0000 9.0000 14.0000 14.0000 14.0000
// 4.0000 9.0000 9.0000 14.0000 14.0000 14.0000
//
// resize(2, in, AF_INTERP_BILINEAR) [10 6 1 1]
// 0.0000 2.5000 5.0000 7.5000 10.0000 10.0000
// 0.5000 3.0000 5.5000 8.0000 10.5000 10.5000
// 1.0000 3.5000 6.0000 8.5000 11.0000 11.0000
// 1.5000 4.0000 6.5000 9.0000 11.5000 11.5000
// 2.0000 4.5000 7.0000 9.5000 12.0000 12.0000
// 2.5000 5.0000 7.5000 10.0000 12.5000 12.5000
// 3.0000 5.5000 8.0000 10.5000 13.0000 13.0000
// 3.5000 6.0000 8.5000 11.0000 13.5000 13.5000
// 4.0000 6.5000 9.0000 11.5000 14.0000 14.0000
// 4.0000 6.5000 9.0000 11.5000 14.0000 14.0000
AF_INTERP_NEAREST
@ AF_INTERP_NEAREST
Nearest Interpolation.
Definition defines.h:243
AF_INTERP_BILINEAR
@ AF_INTERP_BILINEAR
Bilinear Interpolation.
Definition defines.h:245
af_print
#define af_print(...)
Definition util.h:148

## Function Documentation

## ◆ af_resize()

AFAPI af_err af_resize | ( | af_array * | out,
|  | const af_array | in,
|  | const dim_t | odim0,
|  | const dim_t | odim1,
|  | const af_interp_type | method )

C Interface for resizing an image to specified dimensions.

Parameters

  [out] | out | will contain the resized image of specified by `odim0` and `odim1`
  [in] | in | is input image
  [in] | odim0 | is the size for the first output dimension
  [in] | odim1 | is the size for the second output dimension
  [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.

## ◆ resize() [1/3]

AFAPI array resize | ( | const array & | in,
|  | const dim_t | odim0,
|  | const dim_t | odim1,
|  | const interpType | method = AF_INTERP_NEAREST )

C++ Interface for resizing an image to specified dimensions.

Parameters

  [in] | in | is input image
  [in] | odim0 | is the size for the first output dimension
  [in] | odim1 | is the size for the second output dimension
  [in] | method | is the interpolation type (Nearest by default)

Returns
  the resized image of specified by `odim0` and `odim1`

## ◆ resize() [2/3]

AFAPI array resize | ( | const float | scale,
|  | const array & | in,
|  | const interpType | method = AF_INTERP_NEAREST )

C++ Interface for resizing an image to specified scale.

Parameters

  [in] | scale | is scale used for both input dimensions
  [in] | in | is input image
  [in] | method | is the interpolation type (Nearest by default)

Returns
  the image scaled by the specified by `scale`

## ◆ resize() [3/3]

AFAPI array resize | ( | const float | scale0,
|  | const float | scale1,
|  | const array & | in,
|  | const interpType | method = AF_INTERP_NEAREST )

C++ Interface for resizing an image to specified scales.

Parameters

  [in] | scale0 | is scale used for first input dimension
  [in] | scale1 | is scale used for second input dimension
  [in] | in | is input image
  [in] | method | is the interpolation type (Nearest by default)

Returns
  the image scaled by the specified by `scale0` and `scale1`