Book Image

Python Multimedia

By : Ninad Sathaye
Book Image

Python Multimedia

By: Ninad Sathaye

Overview of this book

Multimedia applications are used by a range of industries to enhance the visual appeal of a product. This book will teach the reader how to perform multimedia processing using Python. This step-by-step guide gives you hands-on experience for developing exciting multimedia applications using Python. This book will help you to build applications for processing images, creating 2D animations and processing audio and video. Writing applications that work with images, videos, and other sensory effects is great. Not every application gets to make full use of audio/visual effects, but a certain amount of multimedia makes any application a lot more appealing. There are numerous multimedia libraries for which Python bindings are available. These libraries enable working with different kinds of media, such as images, audio, video, games, and so on. This book introduces the reader to the most widely used open source libraries through several exciting, real world projects. Popular multimedia frameworks and libraries such as GStreamer,Pyglet, QT Phonon, and Python Imaging library are used to develop various multimedia applications.
Table of Contents (13 chapters)
Python Multimedia Beginner's Guide
Credits
About the Author
About the Reviewers
Preface

Time for action – detecting and enhancing edges


Let's see how the edge detection and enhancement filters modify the data of a picture. The photograph that we will use is a close-up of a leaf. The original photo is shown in the next illustration. Applying an edge detection filter on this image creates a cool effect where only edges are highlighted and the remaining portion of the image is rendered as black.

  1. Download the image 0165_3_6_Before_EDGE_ENHANCE.png from the Packt website and save it as Before_EDGE_ENHANCE.png.

  2. Add the following code in a Python file.

    1 import Image
    2 import ImageFilter
    3 import os
    4 paths = [ "C:\images\Before_EDGE_ENHANCE.png ",
    5    "C:\images\After_EDGE_ENHANCE.png ",
    6    "C:\images\EDGE_DETECTION_1.png ",
    7    "C:\images\EDGE_DETECTION_2.png "
    8   ]
    9 paths = map(os.path.normpath, paths)
    10
    11 ( imgPath ,outImgPath1, 
    12 outImgPath2, outImgPath3) = paths
    13 img = Image.open(imgPath)
    14 img1 = img.filter(ImageFilter.FIND_EDGES)
    15 img1.save(outImgPath1)
    16 
    17...