ImageApplyIndexed[f,image]
各画素の行指標と列指標を関数 f の第2引数として,f を image の各画素のチャンネル値のリストに適用する.
ImageApplyIndexed[f,{image1,image2,…}]
f を,各 imageiから取られた一連の対応する画素値に適用する.対応する画素の行および列の指標は f の最終引数として与える.
ImageApplyIndexed
ImageApplyIndexed[f,image]
各画素の行指標と列指標を関数 f の第2引数として,f を image の各画素のチャンネル値のリストに適用する.
ImageApplyIndexed[f,{image1,image2,…}]
f を,各 imageiから取られた一連の対応する画素値に適用する.対応する画素の行および列の指標は f の最終引数として与える.
詳細とオプション
- ImageApplyIndexed[f,image]は,各画素についてのチャンネル値のリストを,関数 f をリストに適用した結果で置換する.
- 2Dでは,各画素の部分指定は{row,column}として f に渡される.
- 3Dでは,部分指定は{slice,row,column}で指定される.
- ImageApplyIndexedは任意のチャンネル数の画像に使うことができる.
- ImageApplyIndexed[f,image]は,image と同じタイプの画像を返す.
- ImageApplyIndexed[f,image]では,関数 f は,数あるいは任意の長さのリストを返すことができる.
- f に渡されるチャンネル値は,一般に,Imageオブジェクトで使われるもとになっているタイプに関係なく,0から1までである.関数 f は,通常0から1までの範囲にあるチャンネル値を返すと想定される.
- ImageApplyIndexed[f,{image1,image2,…,imagen}]で,f には n+1個の引数が与えられる.
- ImageApplyIndexed[f,{image1,image2,…}]は,任意数の同一基準の画像に使うことができる.
- ImageApplyIndexed[f,{image1,image2,…}]は,必要な場合は値を切り取ったり切断したりして,imageiの最大タイプの画像を与える.
- ImageApplyIndexedはImage3Dオブジェクトに使うことができる.
- 次は,使用可能なオプションである.
-
Interleaving True チャンネルがインターリーブされていると仮定するかどうか Masking All 処理する関心領域 - InterleavingTrueの場合,関数 f は指定された画素についてのチャンネル値の完全なリストに適用される.それ以外の場合,f は個々のチャンネル値に適用される.
例題
すべて開く すべて閉じる例 (2)
ImageApplyIndexed[#1 + Max[#2] / 300&, [image]]ImageApplyIndexed[Function[{pixel1, pixel2, pixel3, pixel4, pos},
Which[
Max[pos] < 100, pixel1 + .2,
Max[pos] > 150, (pixel1 + pixel2 + pixel3) / 3,
EuclideanDistance[pos, {125, 125}] < 20, .75 - pixel4,
True, 1 - pixel3]],
{[image], [image], [image], Graphics@Disk[]}]スコープ (3)
オプション (3)
Interleaving (2)
関数がカラーチャンネルに別々に適用されるべきであるときは,Interleaving->Falseを使う:
f[x_Real, pos_] := Piecewise[{{2x, x <= .5}, {2 - 2x, x > .5}}] * Total[pos] / 200
ImageApplyIndexed[f, [image], Interleaving -> False]関数が別々のチャンネル値を期待している場合は,Interleaving->Falseおよび画像のリストを使う:
f[x1_Real, x2_Real, pos_] := With[{x = Max[x1, x2]}, Piecewise[{{2x, x <= .5}, {2 - 2x, x > .5}}] * Total[pos] / 200]
ImageApplyIndexed[f, {[image], [image]}, Interleaving -> False]アプリケーション (6)
結果の各画素がRGBカラーと位置の組合せを表す,5チャンネルの画像を作る:
img = [image];ImageApplyIndexed[Flatten[{#1, #2}]&, img]ImageApplyIndexed[Flatten[{#1, #2 / ImageDimensions[img]}]&, img]ImageApplyIndexed[#1 + Total[Cos[#2 2π / 30]] / 5&, [image]]img = [image];
{w, h} = ImageDimensions[img];
f[pixel_, pos : {row_, column_}] :=
Which[
1 <= row < h / 2 && 1 ≤ column < w / 2, pixel,
row ≥ h / 2 && 1 ≤ column < w / 2, pixel - .2,
1 <= row < h / 2 && column ≥ w / 2, pixel + .4,
True, 1 - pixel
];ImageApplyIndexed[f, img]中心からコーナーに徐々に移動しながら画像をグレースケールに変換する:
image = [image];f = Compile[{{pixel, _Real, 1}, {pos, _Integer, 1}, {dim, _Integer, 1}, {γ, _Real}},
Module[{ρ, α},
ρ = Norm[pos - Reverse[dim] / 2] / (Sqrt[Plus@@(dim ^ 2)] / 2);
α = ρ ^ γ;
(1 - α) * pixel + α * Mean[pixel]
]
];
ImageApplyIndexed[f[#1, #2, ImageDimensions[image], 1]&, image]Table[ImageApplyIndexed[f[#1, #2, ImageDimensions[image], γ]&, image], {γ, {.5, 1, 1.5}}]色相と彩度が画素の位置に依存し,明度が画素値に依存する形で,画像をカラー画像にする:
Image[ImageApplyIndexed[{First[#2] / 256, Last[#2] / 256, #1}&, [image]], ColorSpace -> "HSB"]colors = List@@@{Red, Green, Blue, Yellow};funcs = Table[
Interpolation[N@MapThread[{#1, #2}&, {{{1, 1}, {1, 200}, {200, 1}, {200, 200}}, colors[[All, i]]}], InterpolationOrder -> 1], {i, 3}];
Table[ImageApplyIndexed[f[Sequence@@#2]#1&, [image]], {f, funcs}]//ColorCombine考えられる問題 (1)
Interleaving->Falseとすると,すべての画像のチャンネル数が等しくなければならなくなる:
ImageApplyIndexed[Max[{#1, #2}]&, {[image], [image]}, Interleaving -> False]ImageApplyIndexed[Max[{#1, #2}]&, {[image], [image]}, Interleaving -> True]関連するガイド
テキスト
Wolfram Research (2014), ImageApplyIndexed, Wolfram言語関数, https://reference.wolfram.com/language/ref/ImageApplyIndexed.html.
CMS
Wolfram Language. 2014. "ImageApplyIndexed." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ImageApplyIndexed.html.
APA
Wolfram Language. (2014). ImageApplyIndexed. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageApplyIndexed.html
BibTeX
@misc{reference.wolfram_2026_imageapplyindexed, author="Wolfram Research", title="{ImageApplyIndexed}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/ImageApplyIndexed.html}", note=[Accessed: 05-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_imageapplyindexed, organization={Wolfram Research}, title={ImageApplyIndexed}, year={2014}, url={https://reference.wolfram.com/language/ref/ImageApplyIndexed.html}, note=[Accessed: 05-August-2026]}