ImageChops
(“Channel Operations”) Module¶
The ImageChops
module contains a number of arithmetical image
operations, called channel operations (“chops”). These can be used for various
purposes, including special effects, image compositions, algorithmic painting,
and more.
For more pre-made operations, see ImageOps
.
此时,大部分的信道的操作仅8位图像(例如,“L”和“RGB”)来实现。
功能¶
Most channel operations take one or two image arguments and returns a new image. Unless otherwise noted, the result of a channel operation is always clipped to the range 0 to MAX (which is 255 for all modes supported by the operations in this module).
-
PIL.ImageChops.
add
(image1, image2, scale=1.0, offset=0)[源代码]¶ Adds two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0. At least one of the images must have mode “1”.
out = ((image1 + image2) / scale + offset)
- 返回类型
-
PIL.ImageChops.
add_modulo
(image1, image2)[源代码]¶ 添加两个图像,而不会裁剪结果。至少一个图像必须有模式“1 ”。
out = ((image1 + image2) % MAX)
- 返回类型
-
PIL.ImageChops.
blend
(image1, image2, alpha)[源代码]¶ 混合使用恒定透明度重量图像。别名:PY:甲基:PIL.Image.Image.blend。
- 返回类型
-
PIL.ImageChops.
composite
(image1, image2, mask)[源代码]¶ 创建复合使用透明面罩。别名:PY:甲基:PIL.Image.Image.composite。
- 返回类型
-
PIL.ImageChops.
darker
(image1, image2)[源代码]¶ Compares the two images, pixel by pixel, and returns a new image containing the darker values. At least one of the images must have mode “1”.
out = min(image1, image2)
- 返回类型
-
PIL.ImageChops.
difference
(image1, image2)[源代码]¶ 返回两个图像之间的像素由像素的差的绝对值。至少一个图像必须有模式“1 ”。
out = abs(image1 - image2)
- 返回类型
-
PIL.ImageChops.
duplicate
(image)[源代码]¶ 复制的通道。别名
PIL.Image.Image.copy()
。- 返回类型
-
PIL.ImageChops.
lighter
(image1, image2)[源代码]¶ Compares the two images, pixel by pixel, and returns a new image containing the lighter values. At least one of the images must have mode “1”.
out = max(image1, image2)
- 返回类型
-
PIL.ImageChops.
logical_and
(image1, image2)[源代码]¶ Logical AND between two images. At least one of the images must have mode “1”.
out = ((image1 and image2) % MAX)
- 返回类型
-
PIL.ImageChops.
logical_or
(image1, image2)[源代码]¶ Logical OR between two images. At least one of the images must have mode “1”.
out = ((image1 or image2) % MAX)
- 返回类型
-
PIL.ImageChops.
logical_xor
(image1, image2)[源代码]¶ Logical XOR between two images. At least one of the images must have mode “1”.
out = ((bool(image1) != bool(image2)) % MAX)
- 返回类型
-
PIL.ImageChops.
multiply
(image1, image2)[源代码]¶ Superimposes two images on top of each other.
If you multiply an image with a solid black image, the result is black. If you multiply with a solid white image, the image is unaffected. At least one of the images must have mode “1”.
out = image1 * image2 / MAX
- 返回类型
-
PIL.ImageChops.
offset
(image, xoffset, yoffset=None)¶ Returns a copy of the image where data has been offset by the given distances. Data wraps around the edges. If yoffset is omitted, it is assumed to be equal to xoffset.
-
PIL.ImageChops.
screen
(image1, image2)[源代码]¶ Superimposes two inverted images on top of each other. At least one of the images must have mode “1”.
out = MAX - ((MAX - image1) * (MAX - image2) / MAX)
- 返回类型