Skip to content
Related Articles

Related Articles

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

Sketch is another artistict special effect present in Wand library in python. sketch() function generates a pencil sketched image in output.For best results, radius value should be larger than sigma.

Syntax :




wand.image.sketch( radius, sigma, angle)
# radius should always be greater than sigma(standard deviation)

Parameter :

ParameterInput TypeDescription
radiusnumbers.RealSize of Gaussian apperture.
sigmanumbers.Realstandard deviation of the Gaussian operator.
anglenumbers.Realdirection of blur.

Source Image:

Example #1:






# import display() to show final image
from wand.display import display
  
# import Image from wand.image module
from wand.image import Image
  
# read file using Image function
with Image(filename ="koala.jpeg") as img:
  
    # perform adaptive blur effect using adaptive_blur() function
    img.sketch(0.5, 0.0, 98.0)
  
    # save final image
    img.save(filename ="rb_koala.jpeg")
  
    # display final image
    display(img)

Output :

 

Example #2: To get the best result transform image to grayscale image




# import display() to show final image
from wand.display import display
  
# import Image from wand.image module
from wand.image import Image
  
# read file using Image function
with Image(filename ="koala.jpeg") as img:
  
    # transform to grayscale image
    img.transform_colorspace("gray")
  
    # perform adaptive blur effect using adaptive_blur() function
    img.sketch(0.5, 0.0, 98.0)
  
    # save final image
    img.save(filename ="rb_koala.jpeg")
  
    # display final image
    display(img)

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 :