affineBrick: Affine Transformation (rotation and shift) on Images

View source: R/affineBrick.R

affineBrickR Documentation

Affine Transformation (rotation and shift) on Images

Description

Affine transformations are of type f(x) = Ax + b, where x is the spatial coordinates (2D in this case), A is a rotation matrix (it can also include scale/shear parameters, but only rotation is considered here), and b is the translation (xy shift) parameters.

Usage

affineBrick(Brick, angle = 0, xy_shift = c(0, 0))

Arguments

Brick

An object of class RasterBrick, RasterStack or RasterLayer (from package raster).

angle

A numeric value of the angle (in degrees, 0-360) to rotate Brick. A negative value will change the direction of rotation to clockwise.

xy_shift

A numeric vector of length two with the x and y shift (the translation parameters).

Value

An object of the same class as the input Brick.

Note

Affine transformation affects the image dimension.

See Also

affineCoords(), registerBrick()

Examples

p <- system.file('exdata', 'soybean.tif', package = 'hyperbrick')
im <- brick(p)
print(im)

# view band-3
plot(im[[3]], col = gray.colors(20), asp = 0)

# rotate band-3 at 3.5 degrees counter-clockwise
b3_rot <- affineBrick(im[[3]], angle = 3.5)
plot(b3_rot, add = TRUE, legend = FALSE,
    col = adjustcolor(terrain.colors(20), 0.5))


hyperbrick documentation built on April 1, 2022, 9:07 a.m.