Skip to content
Related Articles

Related Articles

Python – Sharpen and blur filtering using pgmagick
  • Last Updated : 08 May, 2020

Sharpening refers to increase contrast b/w light and dark regions and make image more defined and brings out image features. There are three main reasons to sharpen your image: to overcome blurring introduced by camera equipment, to draw attention to certain areas and to increase legibility. If a blurry text is present in image it becomes easy to read.

Now let’s learn how can we perform image sharpening in pgmagick library in python. We use sharpen() function to sharpen an image.

Code :




# importing library
from pgmagick import Image
  
img = Image('koala.jpg')
  
# sharpening image
img.sharpen(2)
img.write('sharp_koala.jpg')

Output :

Blurring makes an image unclear and foggy. It doubtlessly decrease the clearity of an image. One is not able to see small edges if the image is blurred. Blur is a visual effect that makes the edges of text or images appear fuzzy or out of focus is referred to as a blur. Let’s see how can we blur image use pgmagick in Python.






# importing library
from pgmagick.api import Image
  
img = Image('koala.jpeg')
  
# blur image
img.blur(10, 5)
img.write('blur_koala.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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :