Image

Image[data]

represents a raster image with pixel values given by the array data.

Image[graphics]

creates a raster image from a graphics object.

Image[obj,options]

gives an image that uses the specified options.

Details and Options

  • Image[] displays in a notebook as an image.
  • Image[data] arranges successive rows of data down the page, and successive columns across.
  • In Image[data], each element of data can specify values for any number of channels.
  • Elements of data can be either of the following:
  • vrendered as gray level from 0 (black) to 1 (white)
    {r,g,b}rendered as red, green, blue values from 0 to 1
    {c1,c2,c3,}channel values rendered by equally spaced hues
    colorspecific color
  • Image[data] by default allows any real number, but displays only values between 0 and 1.
  • Image[data,"type"] can be used to create an image of a specified data type. Values in data are coerced to the specified type by rounding or clipping. By default, "Real" is assumed.
  • Possible settings for "type" include:
  • "Bit"integer 0 or 1
    "Byte"integer 0 through 255
    "Bit16"integer 0 through 65535
    "Real32"single-precision real (32 bit)
    "Real"double-precision real (64 bit)
  • Image[image,"type"] can be used to convert between types.
  • Image is treated as a raw object by functions like AtomQ, and for purposes of pattern matching.
  • The following options can be specified:
  • AlignmentPointCenterthe default point in the graphic to align with
    BaselinePositionAutomatichow to align with a surrounding text baseline
    ColorSpaceAutomaticwhat color space to assume for the data
    ImageResolutionAutomaticthe resolution to use when exporting
    ImageSizeAutomaticdisplay size of the image
    InterleavingAutomaticwhether to assume channels are interleaved
    MagnificationAutomatichow to magnify the displayed image
    MetaInformation<||>meta-information associated with the image
  • ColorSpace->cs specifies that values in the data should be interpreted as coordinates in a particular color space cs. ColorSpace->Automatic treats values as arbitrary channel intensities.
  • Image[graphics] effectively uses Rasterize[graphics,"Image"] to rasterize graphics.
  • Image[Raster[]] converts a Raster object to an image.
  • Image[Image[],opts] effectively resets the options for an image.
  • ImageDimensions, ImageChannels and ImageType find information on the structure of an image.
  • Arithmetic and statistical operations such as Log, Plus and Mean can work directly with images.

Background & Context

  • Image provides unified symbolic representation for a large variety of digital image formats (e.g. GIF, PNG, JPG) as found on the internet and elsewhere. In particular, an Image object contains a two-dimensional array of values (or lists of values) that represents a raster image. Images are commonly encountered in digital photography, digitization of text and pictures, scientific visualization, and a wide variety of other fields. The data inside an image may take on a variety of values depending on if the image is binary, grayscale, RGB, CMYK, includes an alpha channel, etc.
  • Upon output, an Image formats as a picture of the actual image, not as a 2D array of values. Image objects may be exported to a variety of standard image formats using Export, and images in a number of formats may be imported as Image objects using Import. Image objects may also be inserted into a notebook by drag-and-drop from external applications.
  • An arbitrary Graphics expression may be converted to an image by applying the function Image to it. Similarly, an image may be converted to a raster expression suitable for display with other Graphics primitives by applying Raster to it. The function Show can be used to combine 2D vector graphics (or Graphics objects) with Image objects.
  • The array of pixel values in an image may be obtained using ImageData. ImageDimensions gives the pixel dimensions of the raster associated with an Image object. ImageType gives a label representing the number type used internally to represent each pixel of an image. Image itself can be used to convert between image types, and ImageAdjust can be used to bring all values of a real-valued image into the range 0 to 1. The number of channels the image contains may be obtained using the function ImageChannels.
  • Options useful for Image objects include ColorSpace, Interleaving, ImageResolution, ImageSize, and Magnification.

Examples

open allclose all

Basic Examples  (3)

Create an image from a 3×3 array:

In[1]:=
Click for copyable input
Out[1]=

Create an RGB channel image from a 3D array:

In[1]:=
Click for copyable input
Out[1]=

Create an image by importing from a file:

In[1]:=
Click for copyable input
Out[1]=

Scope  (19)

Options  (17)

Applications  (2)

Properties & Relations  (8)

See Also

Image3D  DynamicImage  Graphics  Raster  ArrayPlot  Import  Rasterize  ImageData  ImageDimensions  ImageChannels  ImageType  ImageQ  Binarize

Tutorials

Introduced in 2008
(7.0)
| Updated in 2017
(11.1)