Skip to content

Commit b02a66a

Browse files
committed
Merge branch 'pr/635'
Closes realpython#635
2 parents 727ff08 + dff8f0d commit b02a66a

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

docs/scenarios/imaging.rst

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ Image Manipulation
55
.. todo::
66
Add introduction about image manipulation and its Python libraries.
77

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+
813
Python Imaging Library
914
----------------------
1015

1116
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,
1318
its development has stagnated, with its last release in 2009.
1419

1520
Luckily for you, there's an actively-developed fork of PIL called
@@ -55,3 +60,46 @@ Example
5560
5661
There are more examples of the Pillow library in the
5762
`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, more commonly known as OpenCV, is a more advanced image manipulation and processing software than PIL. It has been implemented in several
69+
languages and is widely used.
70+
71+
Installation
72+
~~~~~~~~~~~~
73+
74+
In Python, image processing using OpenCV is implemented using the ``cv2`` and ``NumPy`` modules.
75+
The `installation instructions for OpenCV <http://docs.opencv.org/2.4/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.html#table-of-content-introduction>`_ should guide you through configuring the project for yourself.
76+
77+
NumPy can be downloaded from the Python Package Index(PyPI):
78+
79+
.. code-block:: console
80+
81+
$ pip install numpy
82+
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 Python-implemented examples of OpenCV in this `collection of tutorials <http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_tutorials.html>`_.
105+

0 commit comments

Comments
 (0)