Open In App

Wand level() function in Python

Improve
Improve
Like Article
Like
Save
Share
Report

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




# Import Image from wand.image module
from wand.image import Image
 
# Read image using Image function
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




# Import Image from wand.image module
from wand.image import Image
 
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
    img.level(0.5, 0.7, gamma = 1.1)
    img.save(filename ="kl-level2.jpeg")


Output :
 

 


Last Updated : 10 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads