Image Processing Functions in ArrayFire v3.4

Stefan ArrayFire Leave a Comment

There are a number of  additions and updates to image based features in the new v3.4 release of ArrayFire. Among the updates are:

This blog post will display some typical use cases for these new features.

Interpolation methods

ArrayFire v3.4 implements several new  interpolation methods for 1-d and 2-d domains. The new interpolation methods for 1-d functions are:


and for 2-d functions are:


The behavior of the interpolation methods can be seen in the following pictures.


Original data points

Original data points

Linear interpolation

Linear interpolation

Linear cosine interpolation

Linear cosine interpolation

Cubic interpolation

Cubic interpolation

A common use for interpolation is image filtering. Given a coarse image, we can resample it to be smoother.


The new interpolation methods further apply to several similar image transformation functions:

Different interpolation methods greatly affect the final result of image processing operations. In general, bilinear and bilinear-cosine produce a good result when upscaling an image, however they often result in a blurry look. The bicubic method tends to sharpen the image resulting in slightly stronger borders and a better overall look. Below are some examples of this behavior using image rotation and image scaling.

3x image scaling using nearest-neighbor sampling

3x image scaling using nearest-neighbor sampling

3x image scaling using bilinear-cosine sampling

3x image scaling using bilinear-cosine sampling

3x image scaling using bicubic sampling

3x image scaling using bicubic sampling

  • rot_0

    Image rotation with nearest neighbor sampling.

  • rot_1

    Image rotation with bilinear sampling.

  • rot_2

    Image rotation with bilinear-cosine sampling.

  • rot_3

    Image rotation with bicubic sampling.

Image moments

Image moments are another new addition to ArrayFire v3.4. Image moments are weighted averages of pixels in an image which provide useful properties of an image. A common use of image moments is to find the center of mass or area (or gray level sum) of an image.

Currently, ArrayFire calculates all first order moments. Each moment can be returned individually or all first-order moments can be calculated at once. All moments can be found as follows:

Here is an example of how the shorthand versions might be used to find the area and center of mass of an image:



ArrayFire v3.4 can be downloaded from these locations:


ArrayFire is continually improving through the addition of new image processing and computer vision functions. We welcome your feedback:

Finally, as you find success with ArrayFire, we invite you to contribute a post to this blog to share with the broader community. Email to contribute to this blog.