Last data update: 2014.03.03

R: Image Transposition
transposeR Documentation

Image Transposition

Description

Transposes an image by swapping its first two, i.e., spatial dimensions.

Usage

transpose(x, coerce = FALSE)

Arguments

x

an Image object or an array.

coerce

controls the coercion of x. By default the output is of the same class as the input. If coerce = TRUE then x becomes coerced to an array.

Details

The transposition of an image is performed by swapping the X and Y indices of its array representation.

Value

An Image object or an array, containing x with its XY dimensions transposed. When coerce = TRUE the output is coerced to an array.

Note

transpose is particularly useful when converting between different representations of image data in which the X and Y dimensions are swapped. Typically, in such context only the actual pixel data matters. For performance reasons it is best practice to issue the function directly on an Image object with coerce = TRUE rather than to extract its image data first and only then perform the transposition, or to transpose the Image object and coerce it to an array afterwards.

Author(s)

Andrzej Oles, andrzej.oles@embl.de, 2012

See Also

flip, flop, rotate

Examples

  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)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(EBImage)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/EBImage/transpose.Rd_%03d_medium.png", width=480, height=480)
> ### Name: transpose
> ### Title: Image Transposition
> ### Aliases: transpose
> 
> ### ** Examples
> 
>   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
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>