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

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

Resize an input image. More...

## 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. More...
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. More...
AFAPI array | resize (const float scale, const array &in, const interpType method=AF_INTERP_NEAREST)
| C++ Interface for resizing an image to specified scale. More...
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. More...

## Detailed Description

Resize an input image.

Resizing 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 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

## Function Documentation

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.

AFAPI array af::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`

Examples:
  binary_thresholding.cpp, and image_editing.cpp.

AFAPI array af::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`

AFAPI array af::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`