Wand level() function in Python (original) (raw)

Last Updated : 10 Mar, 2023

level() function controls the black and white boundaries of an image. Similar to the gamma() method, mid-point levels can be adjusted with the gamma keyword argument. The black and white point arguments are expecting values between 0.0 & 1.0 which represent percentages.

Syntax :

wand.image.level(operator, value, channel)

Parameters :

Parameter Input Type Description
black numbers.Real Black point, as a percentage of the system’s quantum range. Defaults to 0..
white numbers.Real White point, as a percentage of the system’s quantum range. Defaults to 1.0.
gamma numbers.Real Optional gamma adjustment. Values > 1.0 lighten the image’s midtones while values < 1.0 darken them.
channel basestring The channel type.

Example 1:
Source Image:

Python3

from wand.image import Image

with Image(filename = "koala.jpeg" ) as img:

`` img.level( 0.2 , 0.9 , gamma = 1.1 )

`` img.save(filename = "kl-level.jpeg" )

Output :

Example 2:
Increasing black and white value to 0.5 and 0.7.

Python3

from wand.image import Image

with Image(filename = "koala.jpeg" ) as img:

`` img.level( 0.5 , 0.7 , gamma = 1.1 )

`` img.save(filename = "kl-level2.jpeg" )

Output :

Similar Reads