diff --git a/docs/scenarios/imaging.rst b/docs/scenarios/imaging.rst index 7ae952d..4dbe427 100644 --- a/docs/scenarios/imaging.rst +++ b/docs/scenarios/imaging.rst @@ -5,11 +5,16 @@ Image Manipulation .. todo:: Add introduction about image manipulation and its Python libraries. +Most image processing and manipulation techniques can be carried out effectively using +two libraries: Python Imaging Library (PIL) and OpenSource Computer Vision (OpenCV). + +A brief description of both is given below. + Python Imaging Library ---------------------- The `Python Imaging Library `_, or PIL -for short, is *the* library for image manipulation in Python. Unfortunately, +for short, is one of the core libraries for image manipulation in Python. Unfortunately, its development has stagnated, with its last release in 2009. Luckily for you, there's an actively-developed fork of PIL called @@ -55,3 +60,46 @@ Example There are more examples of the Pillow library in the `Pillow tutorial `_. + + +OpenSource Computer Vision +-------------------------- + +OpenSource Computer Vision, more commonly known as OpenCV, is a more advanced image manipulation and processing software than PIL. It has been implemented in several +languages and is widely used. + +Installation +~~~~~~~~~~~~ + +In Python, image processing using OpenCV is implemented using the ``cv2`` and ``NumPy`` modules. +The `installation instructions for OpenCV `_ should guide you through configuring the project for yourself. + +NumPy can be downloaded from the Python Package Index(PyPI): + +.. code-block:: console + + $ pip install numpy + + +Example +~~~~~~~ + +.. code-block:: python + + from cv2 import * + import numpy as np + #Read Image + img = cv2.imread('testimg.jpg') + #Display Image + cv2.imshow('image',img) + cv2.waitKey(0) + cv2.destroyAllWindows() + + #Applying Grayscale filter to image + gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + + #Saving filtered image to new file + cv2.imwrite('graytest.jpg',gray) + +There are more Python-implemented examples of OpenCV in this `collection of tutorials `_. +