ImageEnhance Module

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

Example: Vary the sharpness of an image

  1. from PIL import ImageEnhance
  2.  
  3. enhancer = ImageEnhance.Sharpness(image)
  4.  
  5. for i in range(8):
  6. factor = i / 4.0
  7. enhancer.enhance(factor).show("Sharpness %f" % factor)

Also see the enhancer.py demo program in the Scripts/directory.

Classes

All enhancement classes implement a common interface, containing a singlemethod:

  • class PIL.ImageEnhance._Enhance
  • .. py:method:: enhance(factor)

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.

  • class PIL.ImageEnhance.Color(image)
  • Adjust image color balance.

This class can be used to adjust the colour balance of an image, ina manner similar to the controls on a colour TV set. An enhancementfactor of 0.0 gives a black and white image. A factor of 1.0 givesthe original image.

  • class PIL.ImageEnhance.Contrast(image)
  • Adjust image contrast.

This class can be used to control the contrast of an image, similarto the contrast control on a TV set. An enhancement factor of 0.0gives a solid grey image. A factor of 1.0 gives the original image.

  • class PIL.ImageEnhance.Brightness(image)
  • Adjust image brightness.

This class can be used to control the brightness of an image. Anenhancement factor of 0.0 gives a black image. A factor of 1.0 gives theoriginal image.

  • class PIL.ImageEnhance.Sharpness(image)
  • Adjust image sharpness.

This class can be used to adjust the sharpness of an image. Anenhancement factor of 0.0 gives a blurred image, a factor of 1.0 gives theoriginal image, and a factor of 2.0 gives a sharpened image.