source: vendor/python/2.5/Doc/lib/libimageop.tex

Last change on this file was 3225, checked in by bird, 18 years ago

Python 2.5

File size: 4.0 KB
Line 
1\section{\module{imageop} ---
2 Manipulate raw image data}
3
4\declaremodule{builtin}{imageop}
5\modulesynopsis{Manipulate raw image data.}
6
7
8The \module{imageop} module contains some useful operations on images.
9It operates on images consisting of 8 or 32 bit pixels stored in
10Python strings. This is the same format as used by
11\function{gl.lrectwrite()} and the \refmodule{imgfile} module.
12
13The module defines the following variables and functions:
14
15\begin{excdesc}{error}
16This exception is raised on all errors, such as unknown number of bits
17per pixel, etc.
18\end{excdesc}
19
20
21\begin{funcdesc}{crop}{image, psize, width, height, x0, y0, x1, y1}
22Return the selected part of \var{image}, which should by
23\var{width} by \var{height} in size and consist of pixels of
24\var{psize} bytes. \var{x0}, \var{y0}, \var{x1} and \var{y1} are like
25the \function{gl.lrectread()} parameters, i.e.\ the boundary is
26included in the new image. The new boundaries need not be inside the
27picture. Pixels that fall outside the old image will have their value
28set to zero. If \var{x0} is bigger than \var{x1} the new image is
29mirrored. The same holds for the y coordinates.
30\end{funcdesc}
31
32\begin{funcdesc}{scale}{image, psize, width, height, newwidth, newheight}
33Return \var{image} scaled to size \var{newwidth} by \var{newheight}.
34No interpolation is done, scaling is done by simple-minded pixel
35duplication or removal. Therefore, computer-generated images or
36dithered images will not look nice after scaling.
37\end{funcdesc}
38
39\begin{funcdesc}{tovideo}{image, psize, width, height}
40Run a vertical low-pass filter over an image. It does so by computing
41each destination pixel as the average of two vertically-aligned source
42pixels. The main use of this routine is to forestall excessive
43flicker if the image is displayed on a video device that uses
44interlacing, hence the name.
45\end{funcdesc}
46
47\begin{funcdesc}{grey2mono}{image, width, height, threshold}
48Convert a 8-bit deep greyscale image to a 1-bit deep image by
49thresholding all the pixels. The resulting image is tightly packed and
50is probably only useful as an argument to \function{mono2grey()}.
51\end{funcdesc}
52
53\begin{funcdesc}{dither2mono}{image, width, height}
54Convert an 8-bit greyscale image to a 1-bit monochrome image using a
55(simple-minded) dithering algorithm.
56\end{funcdesc}
57
58\begin{funcdesc}{mono2grey}{image, width, height, p0, p1}
59Convert a 1-bit monochrome image to an 8 bit greyscale or color image.
60All pixels that are zero-valued on input get value \var{p0} on output
61and all one-value input pixels get value \var{p1} on output. To
62convert a monochrome black-and-white image to greyscale pass the
63values \code{0} and \code{255} respectively.
64\end{funcdesc}
65
66\begin{funcdesc}{grey2grey4}{image, width, height}
67Convert an 8-bit greyscale image to a 4-bit greyscale image without
68dithering.
69\end{funcdesc}
70
71\begin{funcdesc}{grey2grey2}{image, width, height}
72Convert an 8-bit greyscale image to a 2-bit greyscale image without
73dithering.
74\end{funcdesc}
75
76\begin{funcdesc}{dither2grey2}{image, width, height}
77Convert an 8-bit greyscale image to a 2-bit greyscale image with
78dithering. As for \function{dither2mono()}, the dithering algorithm
79is currently very simple.
80\end{funcdesc}
81
82\begin{funcdesc}{grey42grey}{image, width, height}
83Convert a 4-bit greyscale image to an 8-bit greyscale image.
84\end{funcdesc}
85
86\begin{funcdesc}{grey22grey}{image, width, height}
87Convert a 2-bit greyscale image to an 8-bit greyscale image.
88\end{funcdesc}
89
90\begin{datadesc}{backward_compatible}
91If set to 0, the functions in this module use a non-backward
92compatible way of representing multi-byte pixels on little-endian
93systems. The SGI for which this module was originally written is a
94big-endian system, so setting this variable will have no effect.
95However, the code wasn't originally intended to run on anything else,
96so it made assumptions about byte order which are not universal.
97Setting this variable to 0 will cause the byte order to be reversed on
98little-endian systems, so that it then is the same as on big-endian
99systems.
100\end{datadesc}
Note: See TracBrowser for help on using the repository browser.