Skip to content

createchmimage.py

Chris Churas edited this page Jun 2, 2017 · 17 revisions

createchmimage.py will convert an image to grayscale, then optionally autocontrast, blur, and downsample the image saving it in png format.

By default only the conversion to grayscale is performed.

Please note, regardless of order of optional flags the operations are performed in this order utilizing the Pillow library:

  1. Grayscale
  2. Equalize
  3. AutoContrast
  4. GaussianBlur
  5. Downsample

For more information invoke createchmimage.py --help on the command line.

Examples below use the following image from Pixabay as input:

small corgi

Example invocation no options

Running with no options will convert image to grayscale using Pillow ImageOps.grayscale and write the image out as png file.

createchmimage.py corgi_small.png corgi_small_grayonly.png

grayonly corgi

Example with equalize option

Running with --equalize option will convert image to grayscale and then using Pillow ImageOps.equalize equalize the image before writing it out as a png file.

createchmimage.py corgi_small.png corgi_small_equalize.png --equalize

equalize corgi

Example with autocontrast option

Running with --autocontrast option will convert image to grayscale and then using Pillow ImageOps.autocontrast autocontrast the image before writing it out as a png file.

createchmimage.py corgi_small.png corgi_small_autocon.png --autocontrast

autocontrast corgi

Example with gaussianblur option

Running with --gaussianblur option

createchmimage.py corgi_small.png corgi_small_blur.png --gaussianblur

gaussian blur corgi

Example with downsample option

Running with --downsample 2 option

createchmimage.py corgi_small.png corgi_smal_down2.png --downsample 2

downsample by 2 corgi

Running with --downsample 4 option

createchmimage.py corgi_small.png corgi_smal_down4.png --downsample 4

downsample by 4 corgi