From 5714d409e3dfc4cc0cc66a4f735e95e73cbcee07 Mon Sep 17 00:00:00 2001 From: Shiven Mian Date: Mon, 26 Oct 2015 16:05:01 +0530 Subject: [PATCH 1/3] Added OpenCV to Image Processing --- docs/scenarios/imaging.rst | 51 +++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/docs/scenarios/imaging.rst b/docs/scenarios/imaging.rst index 7ae952d..4b517b7 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,47 @@ Example There are more examples of the Pillow library in the `Pillow tutorial `_. + + +OpenSource Computer Vision +--------------------------- + +OpenSource Computer Vision, or OpenCV in short, is a slightly more advanced and useful +image manipulation and processing software than PIL. It has been implemented in several +languages and is very widely used. + +Installation +~~~~~~~~~~~~~ + +In Python, image processing using OpenCV is implemented using the **cv2** and **NumPy** modules. +Check the installation instructions for OpenCV `here `_. + +NumPy can be easily 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 examples of OpenCV in the documentation +`here `_. + From 6d7c9897b939d737c057d6817715d537edf6a6a8 Mon Sep 17 00:00:00 2001 From: Shiven Mian Date: Mon, 26 Oct 2015 16:23:13 +0530 Subject: [PATCH 2/3] Updated OpenCV --- docs/scenarios/imaging.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/scenarios/imaging.rst b/docs/scenarios/imaging.rst index 4b517b7..4b04859 100644 --- a/docs/scenarios/imaging.rst +++ b/docs/scenarios/imaging.rst @@ -65,7 +65,7 @@ There are more examples of the Pillow library in the OpenSource Computer Vision --------------------------- -OpenSource Computer Vision, or OpenCV in short, is a slightly more advanced and useful +OpenSource Computer Vision, or OpenCV in short, is a more advanced and useful image manipulation and processing software than PIL. It has been implemented in several languages and is very widely used. From dff8f0d9437b60a1d624704545dc96b4439e5559 Mon Sep 17 00:00:00 2001 From: Shiven Mian Date: Sat, 31 Oct 2015 20:21:50 +0530 Subject: [PATCH 3/3] Fixed duplicate target name Address review comments on content of additions and match section title styling of the rest of the guide. --- docs/scenarios/imaging.rst | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/docs/scenarios/imaging.rst b/docs/scenarios/imaging.rst index 4b04859..4dbe427 100644 --- a/docs/scenarios/imaging.rst +++ b/docs/scenarios/imaging.rst @@ -63,26 +63,26 @@ There are more examples of the Pillow library in the OpenSource Computer Vision ---------------------------- +-------------------------- -OpenSource Computer Vision, or OpenCV in short, is a more advanced and useful -image manipulation and processing software than PIL. It has been implemented in several -languages and is very widely used. +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. -Check the installation instructions for OpenCV `here `_. +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 easily downloaded from the Python Package Index(PyPI): +NumPy can be downloaded from the Python Package Index(PyPI): .. code-block:: console $ pip install numpy + Example -~~~~~~~~ +~~~~~~~ .. code-block:: python @@ -101,6 +101,5 @@ Example #Saving filtered image to new file cv2.imwrite('graytest.jpg',gray) -There are more examples of OpenCV in the documentation -`here `_. +There are more Python-implemented examples of OpenCV in this `collection of tutorials `_.