trans2d: 2D Spatial Transformation

View source: R/signal2.R

trans2dR Documentation

2D Spatial Transformation

Description

Perform linear spatial transformations on a matrix, including rigid, similarity, and affine transformations.

Usage

trans2d(x, y, z, pmat,
	rotate = 0, translate = c(0, 0), scale = c(1, 1),
	interp = "linear", dimout = dim(z), ...)

Arguments

x, y, z

The data to be interpolated. Alternatively, x can be a matrix, in which case the matrix elements are used for z and x and y are generated from the matrix's dimensions.

pmat

A 3 x 2 transformation matrix for performing an affine transformation. Automatically generated from rotate, translate, and scale if not provided.

rotate

Rotation in degrees.

translate

Translation vector, in the same units as x and y, if given.

scale

Scaling factors.

interp

Interpolation method. See approx2.

dimout

The dimensions of the returned matrix.

...

Additional arguments passed to approx2.

Value

If x is a matrix or z is provided, returns a transformed matrix with the dimensions of dimout.

Otherwise, only the transformed coordinates are returned in a data.frame.

Author(s)

Kylie A. Bemis

See Also

approx2

Examples

set.seed(1)
x <- matrix(0, nrow=32, ncol=32)
x[9:24,9:24] <- 10
x <- x + runif(length(x))
xt <- trans2d(x, rotate=15, translate=c(-5, 5))

par(mfcol=c(1,2))
image(x, col=hcl.colors(256), main="original")
image(xt, col=hcl.colors(256), main="transformed")

kuwisdelu/matter documentation built on Dec. 8, 2024, 8:09 p.m.