WOLFRAM

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)Summary of the most common use cases

Rectangular array of gray cells:

Out[1]=1

Array of RGB color cells:

Out[1]=1

Array of gray cells with opacity:

Out[1]=1

Array of RGB cells with opacity:

Out[1]=1

Scope  (14)Survey of the scope of standard use cases

Raster Specification  (3)

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

Out[2]=2

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

Out[3]=3

Use Scaled and ImageScaled:

Out[2]=2
Out[3]=3

Use Offset:

Out[2]=2

Raster Styling  (11)

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

Out[2]=2
Out[3]=3

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

Out[2]=2

Specify the range of values:

Out[2]=2

The values outside the specified range are clipped:

Out[2]=2

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

Out[2]=2

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

Out[2]=2
Out[3]=3

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

Out[2]=2

Use Hue values for a scalar matrix:

Out[2]=2

Use a user-defined function:

Out[2]=2

Use a color function with the specified range:

Out[2]=2

Use predefined gradients:

Out[2]=2

Generalizations & Extensions  (1)Generalized and extended use cases

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

Out[2]=2
Out[4]=4

Options  (4)Common values & functionality for each option

ColorFunction  (4)

Use gray level for each cell:

Out[1]=1

Color the raster cells using hue values:

Out[1]=1

Use a user-defined color function:

Out[1]=1

Use a predefined gradient:

Out[1]=1

Applications  (3)Sample problems that can be solved with this function

Use a raster as wallpaper:

Out[2]=2

Get a test RGB raster using ExampleData:

Out[2]=2

Convert RGB to grayscale:

Out[4]=4

Apply a filter using ListCorrelate, then display it:

Out[7]=7

Define a simple raster density plot function:

Set options for the function:

Results:

Out[3]=3
Out[4]=4

Properties & Relations  (7)Properties of the function, and connections to other functions

Rotate can be applied to a raster:

Out[1]=1

Use ArrayPlot when visualizing discrete data:

Out[2]=2

Use ListDensityPlot when visualizing continuous data:

Out[2]=2

Use ReliefPlot to visualize elevation data:

Out[2]=2

Rasterize can generate a raster graphic from any expression:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4
Out[5]=5
Out[6]=6

ExampleData contains a number of test images:

Out[2]=2
Out[3]=3

Many Import formats can produce Raster:

Out[1]=1
Out[2]=2

Possible Issues  (1)Common pitfalls and unexpected behavior

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

Out[2]=2

Neat Examples  (1)Surprising or curious use cases

Different planes through the RGB color space:

Out[1]=1
Wolfram Research (1991), Raster, Wolfram Language function, https://reference.wolfram.com/language/ref/Raster.html (updated 2010).
Wolfram Research (1991), Raster, Wolfram Language function, https://reference.wolfram.com/language/ref/Raster.html (updated 2010).

Text

Wolfram Research (1991), Raster, Wolfram Language function, https://reference.wolfram.com/language/ref/Raster.html (updated 2010).

Wolfram Research (1991), Raster, Wolfram Language function, https://reference.wolfram.com/language/ref/Raster.html (updated 2010).

CMS

Wolfram Language. 1991. "Raster." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2010. https://reference.wolfram.com/language/ref/Raster.html.

Wolfram Language. 1991. "Raster." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2010. https://reference.wolfram.com/language/ref/Raster.html.

APA

Wolfram Language. (1991). Raster. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Raster.html

Wolfram Language. (1991). Raster. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Raster.html

BibTeX

@misc{reference.wolfram_2025_raster, author="Wolfram Research", title="{Raster}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/Raster.html}", note=[Accessed: 23-March-2025 ]}

@misc{reference.wolfram_2025_raster, author="Wolfram Research", title="{Raster}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/Raster.html}", note=[Accessed: 23-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_raster, organization={Wolfram Research}, title={Raster}, year={2010}, url={https://reference.wolfram.com/language/ref/Raster.html}, note=[Accessed: 23-March-2025 ]}

@online{reference.wolfram_2025_raster, organization={Wolfram Research}, title={Raster}, year={2010}, url={https://reference.wolfram.com/language/ref/Raster.html}, note=[Accessed: 23-March-2025 ]}