# Image Processing Functions in ArrayFire v3.4

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

• New interpolation methods for several existing functions
• Functions for image moments

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:

• AF_INTERP_LINEAR_COSINE
• AF_INTERP_CUBIC

and for 2-d functions are:

• AF_INTERP_BILINEAR_COSINE
• AF_INTERP_BICUBIC

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

Original data points

Linear interpolation

Linear cosine 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 bilinear-cosine sampling

3x image scaling using bicubic sampling

• Image rotation with nearest neighbor sampling.

• Image rotation with bilinear sampling.

• Image rotation with bilinear-cosine sampling.

• 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: