Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Wand colorize() function – Python

  • Last Updated : 18 Oct, 2021

Colorized Image refers to image that is blended with a particular color. In order to generate a colorized image we use colorize() function in python Wand. colorize() function blends an image with a constant color. It takes two parameters color and alpha.

Syntax :

 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

wand.image.colorize(color, alpha)

Parameters :



ParameterInput TypeDescription
colorwand.color.ColorColor to paint image with.
alphawand.color.ColorDefines how to blend color.

Source Image:

Example 1:




# import Image with wand.image module
from wand.image import Image
  
# read image using Image() function
with Image(filename ="koala.jpeg") as img:
    # generate colorized image
    img.colorize(color ="yellow", alpha ="rgb(10 %, 0 %, 20 %)")
    img.save(filename ="colorizedkoala.jpeg")

Output:

Example 2:
Increase value of alpha.




from wand.image import Image
  
# read image using Image() function
with Image(filename ="koala.jpeg") as img:
    # generate colorized image
    img.colorize(color ="yellow", alpha ="rgb(25 %, 0 %, 20 %)")
    img.save(filename ="colorizedkoala2.jpeg")

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!