Skip to content
Related Articles

Related Articles

Improve Article
Wand level() function in Python
  • Last Updated : 08 May, 2020

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.evaluate(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.
channelbasestringlThe channel type.

Example 1:

Source Image:






# 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.




# 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 :

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :