The Wayback Machine - https://web.archive.org/web/20240118181718/https://www.geeksforgeeks.org/wand-selective_blur-function-in-wand-python/
Open In App
Related Articles

Wand selective_blur() function in Wand python

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Another kind of Blur that can be performed using Wand library in python 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 threshold. A new attribute named as threshold is introduced in this function.

Syntax :

Python3




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 :

Parameter Input Type Description
radius numbers.Real the radius of the, in pixels, not counting the center pixel.
sigma numbers.Real the standard deviation, in pixels
threshold number.Real Only pixels within contrast threshold are effected.

 

Image Used :  

Example #1:  

Python3




# 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 selective blur effect using
    # selective_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.

Python3




# 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 selective blur effect
    # using selective_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: 

 


Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills, become a part of the hottest trend in the 21st century.
Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 10 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials