Raster
詳細とオプション
- Raster[array,ColorFunction->f]は,関数 f をそのセルに指定された値に適用することで得られるグラフィックス指示子を使ってそれぞれのセルが彩色されるように指定する.
- array の次元が{n,m}の場合,Raster[array]は,長方形Rectangle[{0,0},{m,n}]を充填するとみなされる. »
- Raster[array,{{xmin,ymin},{xmax,ymax}}]は,長方形Rectangle[{xmin,ymin},{xmax,ymax}]を満たすためにラスタを代りに使用するように指定する. »
- ScaledとOffsetは,長方形の座標を指定するのに使用できる.
- Raster[array,Automatic]はRaster[array,{{0,0},{m,n}}]と等価である.
- Raster[array,rect,{amin,amax}]は,amin が0に対応し amax が1に対応するようにセルの値をスケールするように指定する.この範囲外にあるセルの値は0か1になるように切り取られる.
- array はSparseArrayオブジェクトでもよい.
- Image[Raster[…]]はRasterオブジェクトを画像に変換する.
例題
すべて開く すべて閉じる例 (4)
Graphics[Raster[{{0, 0.2, 0.4}, {0.6, 0.8, 1}}]]Graphics[Raster[{{{0, 1, 1}, {1, 0, 1}, {1, 1, 0}}, {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}}]]Graphics[{{Red, Disk[{5, 5}, 4]}, Raster[Table[{1 - x, y}, {x, .1, 1, .1}, {y, .1, 1, .1}]]}]Graphics[{{Red, Disk[{5, 5}, 4]}, Raster[Table[{x, y, x, y}, {x, .1, 1, .1}, {y, .1, 1, .1}]]}]スコープ (14)
ラスタ指定 (3)
×
の行列について,ラスタは{0,0}から{m,n}までの長方形を占める:
a = {{0, 0.2, 0.4}, {0.6, 0.8, 1}};Graphics[Raster[a], Frame -> True, FrameTicks -> False]Graphics[Raster[a, {{0, 1}, {5, 4}}], PlotRange -> {{0, 5}, {0, 5}}, Frame -> True]ScaledとImageScaledを使う:
a = {{0, 0.2, 0.4}, {0.6, 0.8, 1}};Graphics[Raster[a, {Scaled[{0, .3}], Scaled[{1, .7}]}], PlotRange -> {{0, 5}, {0, 5}},
Frame -> True]Graphics[Raster[a, {ImageScaled[{0, .3}], ImageScaled[{1, .7}]}], PlotRange -> {{0, 5}, {0, 5}},
Frame -> True]Offsetを使う:
a = {{0, 0.2, 0.4}, {0.6, 0.8, 1}};Graphics[Raster[a, {Offset[{10, 10}, {0, 0}], Offset[{-10, -10}, {5, 5}]}], PlotRange -> {{0, 5}, {0, 5}},
Frame -> True]ラスタのスタイル (11)
スカラー行列のラスタにはデフォルトでグレーレベルが使われる:
a = {{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1}};Graphics[Raster[a], Frame -> True, FrameTicks -> False]Graphics[Raster[a, ColorFunction -> GrayLevel], Frame -> True, FrameTicks -> False]0から1までの範囲の外にある値は,通常0または1になるように切り取られる:
a = {{-0.4, -0.2, 0, 0.2, 0.4, 0.5, 0.6, 0.8, 1, 1.2, 1.4}};Graphics[Raster[a], Frame -> True, FrameTicks -> False]a = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};Graphics[Raster[a, Automatic, {0, 10}], Frame -> True, FrameTicks -> False]a = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};Graphics[Raster[a, Automatic, {2, 8}], Frame -> True, FrameTicks -> False]数のペアの配列は,不透明度のあるグレーレベルとして扱われる:
a = {{{0, .2}, {0, .4}, {0, .5}, {0, .6}, {0, .8}, {0, 1}}};Graphics[Raster[a], Background -> Cyan]3つの数の配列のラスタには,デフォルトでRGBカラーが使われる:
a = {{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, {{.5, 0, 0}, {0, .5, 0}, {0, 0, .5}}};Graphics[Raster[a]]Graphics[Raster[a, ColorFunction -> RGBColor]]4つの数の配列は不透明度を伴ったRGB値を持つものとして扱われる:
a = {{{1, 0, 0, 1}, {0, 1, 0, 1}, {0, 0, 1, 1}}, {{1, 0, 0, .5}, {0, 1, 0, .5}, {0, 0, 1, .5}}};Graphics[Raster[a], Background -> Cyan]Hueの値をスカラー行列に使う:
a = {{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1}};Graphics[Raster[a, ColorFunction -> Hue]]a = {{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1}};Graphics[Raster[a, ColorFunction -> (Blend[{Red, Blue}, #]&)]]a = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};Graphics[Raster[a, Automatic, {0, 10}, ColorFunction -> (Blend[{Red, Blue}, #]&)]]a = {{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1}};Graphics[Raster[a, ColorFunction -> "AvocadoColors"]]一般化と拡張 (1)
任意のWolfram言語による式を,色関数に適用することができる:
a = {{x, y, y, z, z, z, x}};Graphics[Raster[a, ColorFunction -> (Switch[#, x, Red, y, Green, z, Blue]&)]]b = {{"Tomato", "Gold", "LawnGreen", "SteelBlue"}};Graphics[Raster[b, ColorFunction -> (ColorData["HTML", #]&)]]オプション (4)
ColorFunction (4)
Graphics[Raster[{{0, 0.2, 0.4}, {0.6, 0.8, 1}}, ColorFunction -> GrayLevel]]Graphics[Raster[{{0, 0.2, 0.4}, {0.6, 0.8, 1}}, ColorFunction -> Hue]]Graphics[Raster[{{0, 0.2, 0.4}, {0.6, 0.8, 1}}, ColorFunction -> (RGBColor[#, #, 1 - #]&)]]Graphics[Raster[{Range[0, 1, .1]}, ColorFunction -> "TemperatureMap"]]アプリケーション (3)
r = Raster[Table[i, {i, 100}, {j, 100}], {Scaled[{0, 0}], Scaled[{1, 1}]}, {1, 100}, ColorFunction -> "Pastel"];Plot[{Sin[x], Cos[x], Csc[x]}, {x, 0, 10}, Prolog -> r, PlotStyle -> Thick]ExampleDataを使ってテスト用のRGBラスタを得る:
rgb = Reverse[ExampleData[{"TestImage", "Sailboat"}, "Data"] / 255.];Graphics[Raster[rgb]]gray = Map[{.3, .59, .11}.#&, rgb, {2}];Graphics[Raster[gray]]ListCorrelateを使ってフィルタを適用し,これを表示する:
ker = {{1, 0, -1}, {1, 0, -1}, {1, 0, -1}};f = ListCorrelate[ker, gray];Graphics[Raster[f, Automatic, MinMax[f] / 4, ColorFunction -> "TemperatureMap"]]rasterDensityPlot[f_, {xs_, xmin_, xmax_}, {ys_, ymin_, ymax_}, opts : OptionsPattern[rasterDensityPlot]] := Module[{raw, ppts, cf, zmin, zmax}, {ppts, cf} = OptionValue[{PlotPoints, ColorFunction}];raw = Table[f /. {xs -> j, ys -> i}, {i, ymin, ymax, (ymax - ymin) / (ppts - 1)}, {j, xmin, xmax, (xmax - xmin) / (ppts - 1)}];zmin = Min[raw];zmax = Max[raw];Graphics[Raster[raw, {{xmin, ymin}, {xmax, ymax}}, {zmin, zmax}, ColorFunction -> cf], FilterRules[{opts}, Options[Graphics]], AspectRatio -> 1, Frame -> True]]Options[rasterDensityPlot] = Sort@Join[{PlotPoints -> 50, ColorFunction -> "LakeColors"}, Options[Graphics]];rasterDensityPlot[x Sin[y], {x, -5, 5}, {y, 0, 10}, ColorFunction -> "AvocadoColors"]rasterDensityPlot[Sin[x] Sin[ y], {x, -4, 4}, {y, -4, 4}, ColorFunction -> "SunsetColors"]特性と関係 (7)
Rotateをラスタに適用することができる:
Graphics[Rotate[Raster[Table[{i, j, .5}, {i, 0, 1, .1}, {j, 0, 1, .1}]], Pi / 6]]離散データの可視化にはArrayPlotを用いる:
data = CellularAutomaton[30, {{1}, 0}, 20];{ArrayPlot[data], Graphics[Raster[data]]}連続データの可視化にはListDensityPlotを用いる:
data = Table[Exp[-(x ^ 2 + y ^ 2)], {x, -1.5, 1.5, .1}, {y, -1.5, 1.5, 0.1}];{ListDensityPlot[data, FrameTicks -> None], Graphics[Raster[data]]}標高データの可視化にはReliefPlotを用いる:
data = Table[Evaluate[Sum[Sin[RandomReal[5, 2].{x, y}], {10}]], {x, 0, 10, .04}, {y, 0, 10, .04}];{ReliefPlot[data], Graphics[Raster[data, Automatic, {Min[data], Max[data]}]]}Rasterizeで任意の式からラスタグラフィックスが生成できる:
Rasterize[x ^ 2 + y ^ 2 == 1, "Graphics"]Head[First[%]]Rasterize[Graphics[{EdgeForm[Black], Pink, Disk[]}, ImageSize -> 100], "Graphics"]Head[First[%]]Rasterize[Graphics3D[Sphere[], ImageSize -> 100], "Graphics"]Head[First[%]]ExampleDataには数多くのテスト画像が入っている:
Short[ExampleData["TestImage"]]ExampleData[{"TestImage", "Man"}, "Graphics"]Head[First[%]]Import["ExampleData/coneflower.jpg", "Graphics"]Head[First[%]]考えられる問題 (1)
関連するガイド
履歴
1991 で導入 (2.0) | 1996 で更新 (3.0) ▪ 1999 (4.0) ▪ 2000 (4.1) ▪ 2002 (4.2) ▪ 2003 (5.0) ▪ 2010 (8.0)
テキスト
Wolfram Research (1991), Raster, Wolfram言語関数, https://reference.wolfram.com/language/ref/Raster.html (2010年に更新).
CMS
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
BibTeX
@misc{reference.wolfram_2026_raster, author="Wolfram Research", title="{Raster}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/Raster.html}", note=[Accessed: 03-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_raster, organization={Wolfram Research}, title={Raster}, year={2010}, url={https://reference.wolfram.com/language/ref/Raster.html}, note=[Accessed: 03-November-2026]}