@@ -5,11 +5,16 @@ Image Manipulation
5
5
.. todo ::
6
6
Add introduction about image manipulation and its Python libraries.
7
7
8
+ Most image processing and manipulation techniques can be carried out effectively using
9
+ two libraries: Python Imaging Library (PIL) and OpenSource Computer Vision (OpenCV).
10
+
11
+ A brief description of both is given below.
12
+
8
13
Python Imaging Library
9
14
----------------------
10
15
11
16
The `Python Imaging Library <http://www.pythonware.com/products/pil/ >`_, or PIL
12
- for short, is * the * library for image manipulation in Python. Unfortunately,
17
+ for short, is one of the core libraries for image manipulation in Python. Unfortunately,
13
18
its development has stagnated, with its last release in 2009.
14
19
15
20
Luckily for you, there's an actively-developed fork of PIL called
@@ -55,3 +60,47 @@ Example
55
60
56
61
There are more examples of the Pillow library in the
57
62
`Pillow tutorial <http://pillow.readthedocs.org/en/3.0.x/handbook/tutorial.html >`_.
63
+
64
+
65
+ OpenSource Computer Vision
66
+ ---------------------------
67
+
68
+ OpenSource Computer Vision, or OpenCV in short, is a slightly more advanced and useful
69
+ image manipulation and processing software than PIL. It has been implemented in several
70
+ languages and is very widely used.
71
+
72
+ Installation
73
+ ~~~~~~~~~~~~~
74
+
75
+ In Python, image processing using OpenCV is implemented using the **cv2 ** and **NumPy ** modules.
76
+ Check the installation instructions for OpenCV `here <https://help.ubuntu.com/community/OpenCV >`_.
77
+
78
+ NumPy can be easily downloaded from the Python Package Index(PyPI):
79
+
80
+ .. code-block :: console
81
+
82
+ $ pip install numpy
83
+
84
+ Example
85
+ ~~~~~~~~
86
+
87
+ .. code-block :: python
88
+
89
+ from cv2 import *
90
+ import numpy as np
91
+ # Read Image
92
+ img = cv2.imread(' testimg.jpg' )
93
+ # Display Image
94
+ cv2.imshow(' image' ,img)
95
+ cv2.waitKey(0 )
96
+ cv2.destroyAllWindows()
97
+
98
+ # Applying Grayscale filter to image
99
+ gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY )
100
+
101
+ # Saving filtered image to new file
102
+ cv2.imwrite(' graytest.jpg' ,gray)
103
+
104
+ There are more examples of OpenCV in the documentation
105
+ `here <http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_tutorials.html >`_.
106
+
0 commit comments