RNotes | EBImage


library(EBImage)

Spatial Linear Transformations

par(mfrow=c(1,4))
x <- readImage(system.file("images", "sample.png", package="EBImage"))
display(x)

display( flip(x) )
display( flop(x) ) 
display( resize(x, 128) )

display( rotate(x, 30) )
display( rotate(x,-60, bg="white") )
display( translate(x, c(120, -20)) )

m <- matrix(c(0.6, 0.2, 0, -0.2, 0.3, 300), nrow=3)
m
##      [,1]  [,2]
## [1,]  0.6  -0.2
## [2,]  0.2   0.3
## [3,]  0.0 300.0
display( affine(x, m, bg="white") )

Image Transposition

par(mfrow=c(1,2))
x <- readImage(system.file("images", "sample-color.png", package="EBImage"))
y <- transpose(x)
  
display(x, title='Original')
display(y, title='Transposed')

## performing the transposition of an image twice should result in the original image
z = transpose(y)
identical(x, z)
## [1] TRUE

packageVersion("EBImage")
## [1] '4.8.2'

efg
2015-01-18 2025