[pypy-commit] extradoc extradoc: explain the algorithms, the -b options and the nice abstraction it implements

hakanardo noreply at buildbot.pypy.org
Wed Jul 6 20:37:38 CEST 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: extradoc
Changeset: r3824:34bd12cea418
Date: 2011-07-06 20:46 +0200
http://bitbucket.org/pypy/extradoc/changeset/34bd12cea418/

Log:	explain the algorithms, the -b options and the nice abstraction it
	implements

diff --git a/blog/draft/realtime_image_processing.rst b/blog/draft/realtime_image_processing.rst
--- a/blog/draft/realtime_image_processing.rst
+++ b/blog/draft/realtime_image_processing.rst
@@ -12,7 +12,18 @@
 enough to do realtime video processing using two simple algorithms implemented
 by H&#229;kan Ard&#246;.
 
-XXX: add a very brief description of the algorithms
+sobel.py implements a classical way of locating edges in images,
+`the Sobel operator`:http://en.wikipedia.org/wiki/Sobel_operator. It
+is an approximation of the magnitude of the 
+`image gradient`:http://en.wikipedia.org/wiki/Image_gradient. The
+processing time is spend on two
+`convolutions`:http://en.wikipedia.org/wiki/Convolution between the
+image and 3x3-kernels.
+
+magnify.py implements a pixel coordinate transformation that rearranges
+the pixels in the image to form a magnifying effect in the center.
+It consists of a single loop over the pixels in the output image copying
+pixels from the input image. 
 
 You can try by yourself by downloading the appropriate demo:
 
@@ -39,6 +50,22 @@
 
   $ pypy demo/sobel.py tv://
 
+By default magnify.py uses
+`nearest-neighbor
+interpolation.`:http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation
+By adding the option -b,
+`bilinear interpolation`:http://en.wikipedia.org/wiki/Bilinear_interpolation
+will be used instead, which gives smoother result.
+
+  $ pypy demo/magnify.py -b
+
+There is only a single implementation of the algorithm in
+magnify.py. The two different interpolation methods are implemented by
+subclassing the class used to represent images and embed the
+interpolation within the pixel access method. PyPy is able to achieve good
+performance with this kind of abstractions because it can inline
+virtual methods and specialize functions.
+
 To have a feeling on how much PyPy is faster than CPython, try to run the demo
 with the latter.  On my machine, PyPy runs ``sobel.py`` at ~47.23 fps on
 average, while CPython runs it at ~0.08 fps, meaning that PyPy is **590 times


More information about the pypy-commit mailing list