This module contains a number of classes that can be used for image enhancement.
import ImageEnhance enhancer = ImageEnhance.Sharpness(image) for i in range(8): factor = i / 4.0 enhancer.enhance(factor).show("Sharpness %f" % factor)
Also see the enhancer.py demo program in the Scripts directory.
All enhancement classes implement a common interface, containing a single method:
enhance(factor). Returns an enhanced image. The factor is a floating point value controlling the enhancement. Factor 1.0 always returns a copy of the original image, lower factors means less colour (brightness, contrast, etc), and higher values more. There are no restrictions on this value.
The colour enhancement class is used to colour balance of an image, similar to the controls on a colour TV set. This class implements the enhancement interface as described above.
Color(image). Creates an enhancement object for adjusting colour in an image. A factor of 0.0 gives a black and white image, a factor of 1.0 gives the original image.
The brightness enhancement class is used to control the brightness of an image.
Brightness(image). Creates an enhancement object for adjusting brightness in an image. A factor of 0.0 gives a black image, factor 1.0 gives the original image.
The contrast enhancement class is used to control the contrast of an image, similar to the control on a TV set.
Contrast(image). Creates an enhancement object for adjusting contrast in an image. A factor of 0.0 gives an solid grey image, factor 1.0 gives the original image.
The sharpness enhancement class is used to control the sharpness of an image.
Sharpness(image). Creates an enhancement object for adjusting sharpness in an image. The factor 0.0 gives a blurred image, 1.0 gives the original image, and a factor of 2.0 gives a sharpened image.