Open In App

Wand level() function in Python

Last Updated : 10 Mar, 2023
Comments
Improve
Suggest changes
Like Article
Like
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 : 
 

ParameterInput TypeDescription
blacknumbers.RealBlack point, as a percentage of the system’s quantum range. Defaults to 0..
whitenumbers.RealWhite point, as a percentage of the system’s quantum range. Defaults to 1.0. 
 
gammanumbers.RealOptional gamma adjustment. Values > 1.0 lighten the image’s midtones while values < 1.0 darken them. 
 
channelbasestringThe 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 :
 


 


Next Article
Article Tags :
Practice Tags :

Similar Reads