read.image {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


  choose.image()
  read.image(files, colormode = Grayscale, ...)
  write.image(x, files, quality, ...)

Arguments

x An object of Image-class.
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.
quality A numeric in the range [1,100] defining the quality of non-lossless compression, such as JPEG, when saving images. Higher values correspond to better quality.
... Reserved for future use.

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.

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 read.image a new instance of Image-class.
For choose.image a new instance of Image-class in the TrueColor mode.
For write.image an invisible NULL.

Author(s)

Copyright (c) 2005-2006 Oleg Sklyar : osklyar@ebi.ac.uk

References

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

See Also

Image-class, Image, channel

Examples

  if ( interactive() ) {
    ddir <- paste( system.file(package="EBImage"), "images", sep="/" )
    a <- read.image( paste(ddir, c("A04w0.jpg", "A04w1.jpg"), sep="/") )
    url <- c("http://www.google.com/intl/en/images/logo.gif")
    im <- read.image (url, TrueColor)
    ## Not run: write.image (im, "googlelogo.tif")
    ## Not run: im1 <- channel ( choose.image(), "gray")
  }

[Package EBImage version 2.0.1 Index]