Raster

Raster[{{a11,a12,},}]

is a two-dimensional graphics primitive which represents a rectangular array of gray cells.

Raster[{{{r11,g11,b11},},}]

represents an array of RGB color cells.

Raster[{{{r11,g11,b11,α11},},}]

represents an array of color cells with opacity αij.

Raster[{{{a11,α11},},}]

represents an array of gray cells with the specified opacities.

Details and Options

  • Raster[array,ColorFunction->f] specifies that each cell should be colored using the graphics directives obtained by applying the function f to the value specified for that cell.
  • If array has dimensions {n,m}, then Raster[array] is assumed to occupy the rectangle Rectangle[{0,0},{m,n}]. »
  • Raster[array,{{xmin,ymin},{xmax,ymax}}] specifies that the raster should be taken instead to fill the rectangle Rectangle[{xmin,ymin},{xmax,ymax}]. »
  • Scaled and Offset can be used to specify the coordinates for the rectangle.
  • Raster[array,Automatic] is equivalent to Raster[array,{{0,0},{m,n}}].
  • Raster[array,rect,{amin,amax}] specifies that cell values should be scaled so that amin corresponds to 0 and amax corresponds to 1. Cell values outside this range are clipped to be 0 or 1.
  • array can be a SparseArray object.
  • Image[Raster[]] converts a Raster object to an image.

Examples

open allclose all

Basic Examples  (4)

Rectangular array of gray cells:

Array of RGB color cells:

Array of gray cells with opacity:

Array of RGB cells with opacity:

Scope  (14)

Raster Specification  (3)

For an × matrix, the raster occupies the rectangle {0,0} to {m,n}:

Specify the shape of the raster explicitly, using ordinary coordinates:

Use Scaled and ImageScaled:

Use Offset:

Raster Styling  (11)

A raster of a scalar matrix uses gray level by default:

The values outside the range 0 to 1 are normally clipped to be 0 or 1:

Specify the range of values:

The values outside the specified range are clipped:

An array of pairs of numbers is treated as a gray level with opacity:

A raster of an array of triples uses RGB colors by default:

An array of four numbers is treated as having RGB values with opacity:

Use Hue values for a scalar matrix:

Use a user-defined function:

Use a color function with the specified range:

Use predefined gradients:

Generalizations & Extensions  (1)

Any Wolfram Language expression can be applied to a color function:

Options  (4)

ColorFunction  (4)

Use gray level for each cell:

Color the raster cells using hue values:

Use a user-defined color function:

Use a predefined gradient:

Applications  (3)

Use a raster as wallpaper:

Get a test RGB raster using ExampleData:

Convert RGB to grayscale:

Apply a filter using ListCorrelate, then display it:

Define a simple raster density plot function:

Set options for the function:

Results:

Properties & Relations  (7)

Rotate can be applied to a raster:

Use ArrayPlot when visualizing discrete data:

Use ListDensityPlot when visualizing continuous data:

Use ReliefPlot to visualize elevation data:

Rasterize can generate a raster graphic from any expression:

ExampleData contains a number of test images:

Many Import formats can produce Raster:

Possible Issues  (1)

The first row in the data array is at the bottom of Raster, but at the top of ArrayPlot:

Neat Examples  (1)

Different planes through the RGB color space:

Introduced in 1991
 (2.0)
 |
Updated in 1996
 (3.0)
1999
 (4.0)
2000
 (4.1)
2002
 (4.2)
2003
 (5.0)
2010
 (8.0)