ImageApply[f,image]
将函数 f 应用到 image 中每个像素的通道值列表上.
ImageApply[f,{image1,image2,…}]
将 f 应用到由每个 imagei 中提取的相应像素值组成的序列中.
ImageApply
ImageApply[f,image]
将函数 f 应用到 image 中每个像素的通道值列表上.
ImageApply[f,{image1,image2,…}]
将 f 应用到由每个 imagei 中提取的相应像素值组成的序列中.
更多信息和选项
- ImageApply[f,image] 实现的是一个图像点运算符,将同样的函数应用到图像的每个像素上. 大多数颜色运算(例如颜色转换和量化)都是点运算符.
- ImageApply 适用于任何通道数量的 二维和三维图像.
- 在 ImageApply[f,image] 中,函数 f 可以返回一个数或任意长度的列表.
- 提供给 f 的通道值通常位于范围 0 到 1 之间,不论 image 的基本类型是什么. 假设函数 f 返回的通道值通常位于范围 0 到 1 之内.
- ImageApply[f,{image1,…,imagen}] 实现的是按像素进行计算的图像运算符. 为函数 f 提供 n 个参数. »
- ImageApply[f,{image1,image2,…}] 可处理任意数量的相称图像,给出 imagei 中最大类型的图像,在必要时会剪切或截断数值.
- 可以给出以下选项:
-
Interleaving True 是否把 f 应用于通道值列表或分别应用于每个通道值 Masking All 要处理的感兴趣区域 - f 的计算结果可能会被缓存,以加快获得结果的速度. »
- ImageApply[f,image] 返回与 image 类型相同的图像.
范例
打开所有单元 关闭所有单元基本范例 (2)
范围 (8)
ImageApply[1 - #&, [image]]ImageApply[1 - #&, [image]]ImageApply[(| | | |
| - | - | - |
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |).#&, [image]]ImageApply[Max, [image]]ImageApply[Max, {[image], [image], [image], [image], [image], [image]}]ImageApply[#1 + 1.25 * #2 + #3&, {[image], [image], [image]}]ImageApply[RandomInteger[]#&, [image]]ImageApply[Max, {[image], [image]}]选项 (4)
Interleaving (2)
当函数不得不分别应用于每个颜色通道值时,使用 Interleaving->False:
f[x_Real] := Piecewise[{{2x, x <= .5}, {2 - 2x, x > .5}}]
ImageApply[f, [image], Interleaving -> False]设置 Interleaving->False 下,所有图像应该具有相同的通道数目:
ImageApply[Max, {[image], [image]}, Interleaving -> False]ImageApply[Max, {ColorConvert[[image], "RGB"], [image]}, Interleaving -> False]Masking (2)
ImageApply[1 - #&, [image], Masking -> Graphics[Disk[]]]ImageApply[{##}&, {[image], [image], [image]}, Masking -> [image]]
ImageApply[If[Mean[#4] > 0, Most[{##}], ConstantArray[#1, 3]]&, Flatten@{[image], [image], [image], [image]}]应用 (11)
img = [image];
ImageApply[# ^ 1.6&, img]ImageApply[1 - #&, img]ImageApply[Mean, img]Manipulate[ImageApply[#[[channel]]&, [image]], {{channel, 1}, {1 -> "R", 2 -> "G", 3 -> "B"}}]ImageApply[List@@ColorData["AlpineColors", #]&, [image]]ImageApply[{#, Boole[# > .2]}&, [image]]ImageChannels[%]ImageApply[{1, 0, 0}&, [image], Masking -> [image]]ImageApply[1 / #&, [image]]//ImageAdjustImageApply[#1 / #2&, {[image], [image]}]//ImageAdjust//ColorNegateImport["ExampleData/CThead.tiff", "Image3D"]ImageApply[Max, Import["ExampleData/CThead.tiff"]]ImageApply[Rescale[{##}]&, {[image], [image], [image]}]img = [image];
m = ImageAdjust@GradientFilter[img, 3];
o = ImageAdjust[GradientOrientationFilter[img, 3], {0, 0, 1}, {-Pi / 2, Pi / 2}];
Image[ImageApply[{#2, 1, #1}&, {m, o}], ColorSpace -> "HSB"]i = [image];
ImageApply[Sqrt[#1^2 + #2^2]&, {ImageConvolve[i, (| | |
| - | -- |
| 1 | 0 |
| 0 | -1 |)], ImageConvolve[i, (| | |
| -- | - |
| 0 | 1 |
| -1 | 0 |)]}]属性和关系 (2)
ImageApply 返回与输入具有相同数据类型的图像:
i = Image[{{100}}, "Byte"]ImageApply[1 + #&, i]//ImageTypeImageApply[1 + #&, i]//ImageDataImageApply[1 + #&, Image[i, "Real"]]//ImageData在 ImageApply[f,image] 中,可以缓存 f 的计算以便专注于获取结果的速度:
gray = [image];单个通道 "Byte" 图像使用缓存的计算:
ImageApply[x Sqrt[x], gray]这样会影响结果,如果指定的函数应用于同样的输入给出不同的结果:
ImageApply[x RandomReal[], gray]多通道 "Byte" 图像使用带有缓存计算,其中 Interleaving->False:
image = Image[RandomImage[1, {1024, 1024}, ColorSpace -> "RGB"], "Byte"];res1 = ImageApply[x Sqrt[x], image, Interleaving -> False];//RepeatedTimingres2 = ImageApply[x Sqrt[x], image, Interleaving -> True];//RepeatedTimingres1 == res2多通道 "Byte" 图像使用 Listable 函数缓存计算:
ImageApply[Function[x, Sqrt[x], Listable], image, Interleaving -> True];//RepeatedTiming可能存在的问题 (3)
ImageApply[Reverse, [image]]ImageApply[1 / #&, Image[{{2, 0, 2}}]]ImageApply[1 / #&, Image[{{2, 1, 2}}]]ImageApply 保持图像数据类型,在必要时裁剪或截断值:
image = [image];ImageApply[x x + 0.4, Image[image, "Bit"]]% == image改为将函数应用于 "Real32" 图像:
ImageApply[x x + 0.4, Image[image, "Real32"]]巧妙范例 (4)
ImageApply[RotateLeft, [image]]ImageApply[If[#[[1]] > #[[2]] + #[[3]], #, ConstantArray[Mean[#], 3]]&, [image]]ImageApply[TriangleWave, [image]]ImageApply[ {Sin[Pi # * 4], Sin[Pi #], Sin[Pi# * 3]}&, [image]]技术笔记
-
▪
- 图像处理
文本
Wolfram Research (2008),ImageApply,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ImageApply.html (更新于 2012 年).
CMS
Wolfram 语言. 2008. "ImageApply." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2012. https://reference.wolfram.com/language/ref/ImageApply.html.
APA
Wolfram 语言. (2008). ImageApply. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/ImageApply.html 年
BibTeX
@misc{reference.wolfram_2026_imageapply, author="Wolfram Research", title="{ImageApply}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/ImageApply.html}", note=[Accessed: 31-October-2026]}
BibLaTeX
@online{reference.wolfram_2026_imageapply, organization={Wolfram Research}, title={ImageApply}, year={2012}, url={https://reference.wolfram.com/language/ref/ImageApply.html}, note=[Accessed: 31-October-2026]}