Pillow/docs/reference/ImageEnhance.rst

76 lines
2.2 KiB
ReStructuredText
Raw Normal View History

2013-10-13 00:48:34 +04:00
.. py:module:: PIL.ImageEnhance
.. py:currentmodule:: PIL.ImageEnhance
:py:mod:`~PIL.ImageEnhance` Module
==================================
2013-10-13 00:48:34 +04:00
The :py:mod:`~PIL.ImageEnhance` module contains a number of classes that can be used
2013-10-13 00:48:34 +04:00
for image enhancement.
2013-10-13 04:14:12 +04:00
Example: Vary the sharpness of an image
---------------------------------------
2013-10-13 00:48:34 +04:00
::
2013-10-13 00:48:34 +04:00
2013-10-13 00:53:31 +04:00
from PIL import ImageEnhance
2013-10-13 00:48:34 +04:00
enhancer = ImageEnhance.Sharpness(image)
for i in range(8):
factor = i / 4.0
enhancer.enhance(factor).show(f"Sharpness {factor:f}")
2013-10-13 00:48:34 +04:00
Also see the :file:`enhancer.py` demo program in the :file:`Scripts/`
directory.
Classes
-------
All enhancement classes implement a common interface, containing a single
method:
2020-06-14 18:16:15 +03:00
.. py:class:: _Enhance
2017-12-30 13:23:04 +03:00
.. py:method:: enhance(factor)
2013-10-13 00:48:34 +04:00
2017-12-30 13:23:04 +03:00
Returns an enhanced image.
:param factor: A floating point value controlling the enhancement.
Factor 1.0 always returns a copy of the original image,
lower factors mean less color (brightness, contrast,
etc), and higher values more. There are no restrictions
on this value.
2020-06-14 18:16:15 +03:00
.. py:class:: Color(image)
2017-12-30 13:23:04 +03:00
Adjust image color balance.
This class can be used to adjust the colour balance of an image, in
a manner similar to the controls on a colour TV set. An enhancement
factor of 0.0 gives a black and white image. A factor of 1.0 gives
the original image.
2020-06-14 18:16:15 +03:00
.. py:class:: Contrast(image)
2017-12-30 13:23:04 +03:00
Adjust image contrast.
This class can be used to control the contrast of an image, similar
to the contrast control on a TV set. An enhancement factor of 0.0
gives a solid grey image. A factor of 1.0 gives the original image.
2020-06-14 18:16:15 +03:00
.. py:class:: Brightness(image)
2017-12-30 13:23:04 +03:00
Adjust image brightness.
This class can be used to control the brightness of an image. An
enhancement factor of 0.0 gives a black image. A factor of 1.0 gives the
original image.
2020-06-14 18:16:15 +03:00
.. py:class:: Sharpness(image)
2017-12-30 13:23:04 +03:00
Adjust image sharpness.
This class can be used to adjust the sharpness of an image. An
enhancement factor of 0.0 gives a blurred image, a factor of 1.0 gives the
original image, and a factor of 2.0 gives a sharpened image.