Learn R Programming

RsimMosaic (version 1.0.2)

bilinearInterpolator: A function to perform bilinar interpolation

Description

This function is just a wrapper to the interp.surface.grid function to perform bilinar interpolation of a regular matrix.

Usage

bilinearInterpolator(oldMatrix, pointsInNewX, pointsInNewY)

Arguments

oldMatrix
The original matrix.
pointsInNewX
The number of points in the new matrix (the number of new rows).
pointsInNewY
The number of points in the new matrix (the number of new columns).

Value

It returns an interpolated matrix. The size of the new matrix is pointsInNewX rows and pointsInNewY columns.

See Also

interp.surface.grid

Examples

Run this code
library('jpeg')
 
# Read the R logo
logo <- readJPEG(system.file("img", "Rlogo.jpg", package="jpeg"))

# Create a scaled down version of the R channel
intrpArray <- array(dim=c(20, 20, 3))
intrpArray[,,1] <- bilinearInterpolator(logo[,,1], dim(intrpArray)[1], dim(intrpArray)[2])

# Display the results
dev.new()
image(logo[,,1], main="Original")
dev.new()
image(intrpArray[,,1], main="Scaled down")

Run the code above in your browser using DataLab