Given a series of X and Y coordinates and an array/matrix, interpolates the Z coordinate using bilinear interpolation.

interpolate_array(image, x, y)

Arguments

image

Image filename, a matrix, or a 3-layer RGB array.

x

X indices (or fractional index) to interpolate.

y

Y indices (or fractional index) to interpolate.

Value

Either a vector of values (if image is a matrix) or a list of interpolated values from each layer.

Examples

#if(interactive()){
#Interpolate a matrix
interpolate_array(volcano,c(10,10.1,11),c(30,30.5,33))
#> [1] 141.00 139.75 136.00
#Interpolate a 3-layer array (returns list for each channel)
interpolate_array(dragon,c(10,10.1,11),c(30,30.5,33))
#> $r
#> [1] 0.1212292 0.1245874 0.1293542
#> 
#> $g
#> [1] 0.2294457 0.2332487 0.2407946
#> 
#> $b
#> [1] 0.1288862 0.1320293 0.1379057
#> 
#> $a
#> [1] 0.1288862 0.1320293 0.1379057
#> 
#end}