back next

The ImageEnhance Module

The ImageEnhance module contains a number of classes that can be used for image enhancement.

Example #

Vary the Sharpness of an Image
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.

Interface #

All enhancement classes implement a common interface, containing a single method:

enhancer.enhance(factor) ⇒ image

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 mean less color (brightness, contrast, etc), and higher values more. There are no restrictions on this value.

The Color Class #

The color enhancement class is used to adjust the color balance of an image, in a manner similar to the controls on a color TV set. This class implements the enhancement interface as described above.

ImageEnhance.Color(image) ⇒ Color enhancer instance

Creates an enhancement object for adjusting color 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 Class #

The brightness enhancement class is used to control the brightness of an image.

ImageEnhance.Brightness(image) ⇒ Brightness enhancer instance

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 Class #

The contrast enhancement class is used to control the contrast of an image, similar to the contrast control on a TV set.

ImageEnhance.Contrast(image) ⇒ Contrast enhancer instance

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 Class #

The sharpness enhancement class is used to control the sharpness of an image.

ImageEnhance.Sharpness(image) ⇒ Sharpness enhancer instance

Creates an enhancement object for adjusting the sharpness of 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.

 

A Django site. rendered by a django application. hosted by webfaction.