Skip to content
Related Articles

Related Articles

Improve Article

Python – shade() function in Wand

  • Last Updated : 08 May, 2020

shade() function generates a 3d kind of image or creates a 3d effect by simulating a light from an elevated angle. azimuth parameter is used to control the X and Y angle and elevation parameter is used to control the z agle of the image. We can also get final image in grayscale by putting gray parameter as true.

Syntax :

wand.image.shade(gray, azimuth, elevation);

Parameters :

ParameterInput TypeDescription
graybooleanIsolate the effect on pixel intensity. Default is False.
azimuthnumbers.realAngle from x-axis.
elevationnumber.RealAmount of pixels from the z-axis.

Source Image:

Example 1:






# import Image from wand.image module
from wand.image import Image
  
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
  
    # generating shaded image using shade() function.
    img.shade(gray = True,
              azimuth = 286.0,
              elevation = 45.0)
  
    img.save(filename ="shadekoala.jpeg")

Output:

Example 2: setting gray as False, increasing azimuth and elevation value.




# import Image from wand.image module
  
from wand.image import Image
  
with Image(filename ="koala.jpeg") as img:
    # generating shaded image using shade() function.
    img.shade(gray = True,
              azimuth = 298.0,
              elevation = 70.0)
  
    img.save(filename ="shadekoala_2.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 :