Skip to content
Related Articles

Related Articles

Improve Article
Wand selective_blur() function in Wand python
  • Last Updated : 22 Apr, 2020

Another kind of Blur that can be performed using Wand library in pytho is Selective Blur. Selective blur is similar to normal blur. Difference is that it only effect the part of the image that have contrast below a given quantum threshhold. A new attribute named as threshold is introduced in this function.

Syntax :




wand.image.selective_blur(radius= radius_value, sigma= sigma_value,
                          threshold= thrshold_value, 
                          channel = "optional_channel_value")
  
# radius should always be greater than sigma(standard deviation)

Parameters :

ParameterInput TypeDescription
radiusnumbers.Realthe radius of the, in pixels, not counting the center pixel.
sigmanumbers.Realthe standard deviation, in pixels
thresholdnumber.RealOnly pixels within contrast threshold are effected.

Image Used :

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.selective_blur(radius = 8, sigma = 4
              threshold = 0.15 * img.quantum_range)
  
    # save final image
    img.save(filename ="mb_koala.jpeg")
  
    # display final image
    display(img)

Output:

 

Example #2: Increase threshold value to 0.5.




# 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.selective_blur(radius = 8, sigma = 4
              threshold = 0.25 * img.quantum_range)
  
    # save final image
    img.save(filename ="mb_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 :