O'Reilly logo

Python Multimedia Beginner's Guide by Ninad Sathaye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - smoothing an image

Let's work out an example where a smoothing filter will be applied to an image.

  1. Download the image file 0165_3_Before_SMOOTHING.png from the Packt website and save it as Before_SMOOTHING.png.
  2. This is a low-resolution image scanned from a developed photograph. As you can see, there is a lot of salt-and-pepper noise in the image. We will apply smoothing filter to reduce some of this noise in the image data.
  3. Add the following code in a Python file.
    import ImageFilter
    import Image
    img = Image.open( "C:\\images\\Before_SMOOTH.png ")
    img = img.filter(ImageFilter.SMOOTH)
    img.save( "C:\\images\\ch3\\After_SMOOTH.png")
    img.show()
    
  4. The highlighted line in the code is where the smoothing filter is applied to the image. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required