readImage {EBImage}R Documentation

Image I/O

Description

Functions to choose, read and write images from/to files and URL's. Supported image formats are determined by the ImageMagick installation.

Usage

  chooseImage(colormode = Grayscale)
  readImage(files, colormode = Grayscale, ...)

  ## S4 method for signature 'Image':
  writeImage(x, files, ...)

Arguments

x An object of Image.
files A character vector of files/URL's to read from or to write to.
colormode An integer value for the color mode of images after they are read. By default all images will be converted to Grayscale on read.
... Reserved.

Details

If files is missing when writing images, fileName(x) method will be used to select a single file to write to. Otherwise, the length of this vector must be equal either 1 or the number of 2D images in the stack.

When writing images in formats supporting non-lossless compression (like JPEG), the quality can be spcified used a numeric quality argument with the range [1,100]. Higher values correspond to better quality. Defaults to 95.

The file format is deduced from the file name extension(s), there is neither a need nor a way to specify the format explicitly.

ImageMagick is used to perform all image I/O operations. Therefore, the package supports all the file types supported by ImageMagick.

When reading images, files of different formats can be mixed in any consequence, including mixing single 2D images with TIFF image stacks. The result will contain a stack of all images and stacks cropped (filled with background if images are smaller) at the size of the first image read.

choose.image is an interactive function that does not return to R until either Ok or Cancel button is pressed in the GUI dialog. It uses GTK+2 File Open Dialog to select images. Multiple images can be selected and loaded at once. By default this functions reads images as TrueColor. This function will produce an error message if the package was compiled without GTK+ support.

Value

For readImage and chooseImage a new instance of Image.
For writeImage an invisible NULL.

Author(s)

Oleg Sklyar, osklyar@ebi.ac.uk, 2005-2006

References

ImageMagick: http://www.imagemagick.org.

See Also

Image, Image, channel

Examples

    f <- paste( system.file(package="EBImage"), "images/Gene1_G.tif", sep="/" )
    ii = readImage(f)
  if ( interactive() ) {
    url <- c("http://www.google.com/intl/en/images/logo.gif")
    im <- readImage (url, TrueColor)
    ## Not run: writeImage (im, "googlelogo.tif")
    ## Not run: im1 <- channel ( chooseImage(), "gray")
  }

[Package EBImage version 2.2.0 Index]