ImageFileApply[f,inputfile,outputfile]
関数 f を inputfile に保存された画像の各画素のチャンネル値のリストに適用し,結果を outputfile に保存する
ImageFileApply
ImageFileApply[f,inputfile,outputfile]
関数 f を inputfile に保存された画像の各画素のチャンネル値のリストに適用し,結果を outputfile に保存する
詳細とオプション
- ImageFileApplyを使って,利用可能なメモリ数を超える可能性がある非常に大きい画像ファイルをブロックごとに連続的に読み込み,処理し,書き込むことができる.
- ImageFileApply[f,inputfile]は,結果を$WolframDocumentsDirectoryの"Image"ディレクトリに保存する.
- ImageFileApplyは,TIFFファイル,JPEGファイル,PNGファイルに使うことができる.作成された outputfile は,常に inputfile と同じファイル形式,データタイプ,大きさである.
- ImageFileApplyは任意のチャンネル数の画像に使うことができる.
- 画像ファイルの inputfile および outputfile は文字列として,あるいはFileオブジェクトとして与えることができる.
- 関数 f は常に数あるいは任意長のリストを返さなければならない.
- f に渡されるチャンネル値は,通常は,Imageオブジェクトに使われるもとになったタイプとは関係なく,0から1の範囲である.関数 f は,通常0から1の範囲にあるチャンネル値を返すと考えられる.
- 使用可能なオプション
-
Interleaving True f にチャンネル値のリストを与えるかどうか Method Automatic 使用するメソッド - Methodには次のサブオプションを与えることができる.
-
"ImageList" All 画像が複数あるファイル中の処理すべきフレーム "MaxBlockSize" 8000000 メモリにロードする画像ブロックの最大サイズ(単位:画素) - 最も効率のよいファイル処理をするために,画像のストライプあるいはタイルには特定の順序でアクセスすることがある.
- オプション"MaxBlockSize"の値は,入力ファイルについてサポートされる最小ブロックより小さい場合は,超えられることがある.
- "ImageList"->{l1,l2,…}とすると,出力画像には処理されたフレームしか含まれない.
例題
すべて開く すべて閉じる例 (2)
file = ImageFileApply[1 - #&, ExampleData[{"TestImage", "Apples"}, "FilePath"]]Thumbnail[%]ImageFileApply[Mean, ExampleData[{"TestImage", "Flower"}, "FilePath"], "ImageFileApply-example.jpeg"]オプション (3)
Interleaving (1)
各チャンネルに別々に関数を適用しなければならない場合はInterleaving->Falseを使う:
f[x_Real] := Piecewise[{{2x, x <= .5}, {2 - 2x, x > .5}}];
ImageFileApply[f, ExampleData[{"TestImage", "RadcliffeCamera"}, "FilePath"], Interleaving -> False]Thumbnail[%]Method (2)
"ImageList"を使って,複数の画像があるファイルの1フレームのみに関数を適用する:
path = ExampleData[{"TestImage3D", "Orbits"}, "FilePath"];Import@ImageFileApply[1 - #&, path, Method -> {"ImageList" -> 50}]Import@ImageFileApply[1 - #&, path, Method -> {"ImageList" -> {50, 60}}]"MaxBlockSize"の適切な値を選ぶと,パフォーマンスが著しく向上することがある:
path = ExampleData[{"TestImage", "Marruecos"}, "FilePath"];Table[
AbsoluteTiming[ImageFileApply[# ^ 2&, path, Method -> {"MaxBlockSize" -> size}];]//First, {size, {1000000, 8000000}}]アプリケーション (2)
ImageFileApply[Boole[# < 0.7]&, ExampleData[{"TestImage", "ResolutionChart"}, "FilePath"]]Thumbnail[%]ImageFileApply[0.5#&, ExampleData[{"TestImage", "Boat"}, "FilePath"]]Thumbnail[%]テキスト
Wolfram Research (2012), ImageFileApply, Wolfram言語関数, https://reference.wolfram.com/language/ref/ImageFileApply.html (2020年に更新).
CMS
Wolfram Language. 2012. "ImageFileApply." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/ImageFileApply.html.
APA
Wolfram Language. (2012). ImageFileApply. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageFileApply.html
BibTeX
@misc{reference.wolfram_2026_imagefileapply, author="Wolfram Research", title="{ImageFileApply}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/ImageFileApply.html}", note=[Accessed: 30-October-2026]}
BibLaTeX
@online{reference.wolfram_2026_imagefileapply, organization={Wolfram Research}, title={ImageFileApply}, year={2020}, url={https://reference.wolfram.com/language/ref/ImageFileApply.html}, note=[Accessed: 30-October-2026]}