| Contents | Index |
plot::Raster
translates a matrix
of RGB values into a regular 2D mesh of rectangles extending from the lower left corner (
,
) to the upper right corner (
,
). The rectangles are colored according to the color entries in
.
Calls:
plot::Raster(A, Options)
plot::Raster(A, x =
..
, y =
..
, <a = amin .. amax>, Options)
plot::Raster(L, Options)
plot::Raster(L, x =
..
, y =
..
, <a = amin .. amax>, Options)
Parameters:
|
A: |
an array of domain type DOM_ARRAY or a matrix of category Cat::Matrix (e.g., of type matrix or densematrix) providing RGB values or color expressions of the animation parameter |
|
L: |
a list of lists RGB values or color expressions of the animation parameter |
|
x: |
name of the horizontal variable: an identifier or an indexed identifier. It is used as the title of the coordinate axis in |
|
|
the range of the horizontal variable: |
|
y: |
name of the vertical variable: an identifier or an indexed identifier. It is used as the title of the coordinate axis in |
|
|
the range of the vertical variable: |
See Also:
import::readbitmap, plot, plot::copy, plot::Density, plot::Inequality
Details:
plot::Raster serves for generating 2D raster objects such as bitmaps. External bitmap data can be imported to a MuPAD® session via import::readbitmap. The resulting array of color values can be passed directly to plot::Raster to embed the imported bitmap in a 2D MuPAD scene.
When color values are specified by an array or a matrix
, the low indices correspond to the lower left corner of the graphics. The high indices correspond to the upper right corner.
Note that the bitmap data of most standard graphical formats are stored in the usual Western reading order: the first pixels correspond to the upper left corner, the last pixels correspond to the lower right corner. The utility import::readbitmap produces an array in which the first element corresponds to the lower left corner. Bitmap data imported this way can be passed directly to plot::Raster.
Arrays/matrices do not need to be indexed from
. E.g.,
A = array(
,
, [..RGB values..])
yields a graphical array with
,
.
If no plot range
,
is specified,
,
,
, ![]()
is used.
When color values are specified by a list of lists
, the first entries in the list correspond to the lower left corner of the graphics. The last entries correspond to the upper right corner.
If no plot range
,
is specified,
,
,
, ![]()
is used, where
is the length of
and
is the (common) length of the sublists in
. All sublists (“rows”) must have the same length.
Animations are triggered by specifying a range a = amin .. amax for a parameter a that is different from the variables x, y. Thus, in animations, both the ranges
,
as well as the animation range
must be specified.
The related plot routine plot::Density provides a similar functionality offering an automatic color scheme based on scalar density values.
Example 1
We generate a raster plot:
checkerboard:= array(1..8, 1..8):
for i from 1 to 8 do
for j from 1 to 8 do
if i + j mod 2 = 0 then
checkerboard[i,j] := RGB::Black;
else
checkerboard[i,j] := RGB::White;
end_if;
end_for:
end_for:
p := plot::Raster(checkerboard):
The plot object is rendered:
plot(p):

delete checkerboard, p:
Example 2
We import an external bitmap file:
[width, height, colordata] := import::readbitmap("Eva.jpeg"):
The array colordata can be passed directly to plot::Raster:
scenewidth:= 80*unit::mm:
sceneheight:= height/width*scenewidth:
plot(plot::Raster(colordata),
Width = scenewidth,
Height = sceneheight,
Footer = "This is Eva"):

delete width, height, colordata, scenewidth, sceneheight:
Example 3
This is Tom:
[widthT, heightT, Tom] := import::readbitmap("Tom.jpeg", ReturnType=DOM_ARRAY):
plot(plot::Raster(Tom), Width = widthT/3, Height = heightT/3):

This is Jerry:
[widthJ, heightJ, Jerry] := import::readbitmap("Jerry.jpeg", ReturnType=DOM_ARRAY):
plot(plot::Raster(Jerry), Width = widthT/3, Height = heightT/3):

Although they look different, they are topologically equivalent. We demonstrate this by deforming Tom to Jerry via a smooth map
,
:
blend := (T, J, a) -> zip(T, J, (t,j) -> (1-a)*t + a*j):
Tom2Jerry:= array(1..heightT, 1..widthT):
for i from 1 to heightT do
for j from 1 to widthT do
Tom2Jerry[i, j]:= blend(Tom[i, j], Jerry[i, j], a):
end_for:
end_for:
The following call produces an animated plot of the deformation. Note that
and
ranges must be specified for an animation:
plot(plot::Raster(Tom2Jerry,
x = 1..widthT,
y = 1..heightT,
a = 0..1, Frames = 10,
Footer = "Tom & Jerry"),
Width = widthT/3, Height = heightT/3):


This is the arithmetical mean of Tom and Jerry:
plot(plot::Raster(map(subs(Tom2Jerry, a = 0.5), eval)),
Footer = "(Tom + Jerry)/2", FooterFont = [12],
Width = widthT/3, Height = heightT/3):


Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |