Skip to content
Related Articles

Related Articles

Wand unsharp_mask() function – Python

View Discussion
Improve Article
Save Article
  • Last Updated : 18 Oct, 2021

unsharp_mask() is similar to normal sharpen() method in python Wand, but it gives control toblend between filter and original(amount parameter), and the threshold. When the amount value is greater than 1.0 more if the sharpen filter is applied, and less if the value is under 1.0. Values for threshold over 0.0 reduce the sharpens.
 

Syntax : 
 

Python3




wand.image.unsharp_mask(radius, sigma, amount, threshold)

Parameters : 
 

ParameterInput TypeDescription
radiusnumbers.RealSize of gaussian aperture.
sigmanumbers.Realthe standard deviation of the Gaussian, in pixels.
amountnumbers.RealThe percentage of the difference between the original and the blur image that is added back into the original
thresholdnumbers.RealThe threshold in pixels needed to apply the difference amount.

 

Source Image : 
 

Example 1: 
 

Python3




# import Image from wand.image module
from wand.image import Image
 
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
 
    # generating sharp image using unsharp_sharpen() function.
    img.unsharp_mask(radius = 10,
                     sigma = 4,
                     amount = 1,
                     threshold = 0)
    img.save(filename ="unsharpmaskkoala.jpeg")

Output: 
 

Example 2: Increasing threshold value to 0.5 and decreasing radius and sigma. 
 

Python3




# import Image from wand.image module
from wand.image import Image
 
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
 
    # generating sharp image using unsharp_sharpen() function.
    img.unsharp_mask(radius = 8,
                     sigma = 4,
                     amount = 1,
                     threshold = 0.5)
    img.save(filename ="unsharpmaskkoala.jpeg")

Output: 
 

 


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!