improve treatment of multi-line replies, ignore empty lines
[python/dscho.git] / Doc / libimageop.tex
blob4481e614c1cb6bfaaab15aaea3c6ecded5522be4
1 \section{Built-in module \sectcode{imageop}}
2 \bimodindex{imageop}
4 The imageop module contains some useful operations on images.
5 It operates on images consisting of 8 or 32 bit pixels
6 stored in python strings. This is the same format as used
7 by \code{gl.lrectwrite} and the \code{imgfile} module.
9 The module defines the following variables and functions:
11 \renewcommand{\indexsubitem}{(in module imageop)}
13 \begin{excdesc}{error}
14 This exception is raised on all errors, such as unknown number of bits
15 per pixel, etc.
16 \end{excdesc}
19 \begin{funcdesc}{crop}{image\, psize\, width\, height\, x0\, y0\, x1\, y1}
20 This function takes the image in \code{image}, which should by
21 \code{width} by \code{height} in size and consist of pixels of
22 \code{psize} bytes, and returns the selected part of that image. \code{x0},
23 \code{y0}, \code{x1} and \code{y1} are like the \code{lrectread}
24 parameters, i.e. the boundary is included in the new image.
25 The new boundaries need not be inside the picture. Pixels that fall
26 outside the old image will have their value set to zero.
27 If \code{x0} is bigger than \code{x1} the new image is mirrored. The
28 same holds for the y coordinates.
29 \end{funcdesc}
31 \begin{funcdesc}{scale}{image\, psize\, width\, height\, newwidth\, newheight}
32 This function returns a \code{image} scaled to size \code{newwidth} by
33 \code{newheight}. No interpolation is done, scaling is done by
34 simple-minded pixel duplication or removal. Therefore, computer-generated
35 images or dithered images will not look nice after scaling.
36 \end{funcdesc}
38 \begin{funcdesc}{tovideo}{image\, psize\, width\, height}
39 This function runs a vertical low-pass filter over an image. It does
40 so by computing each destination pixel as the average of two
41 vertically-aligned source pixels. The main use of this routine is to
42 forestall excessive flicker if the image is displayed on a video
43 device that uses interlacing, hence the name.
44 \end{funcdesc}
46 \begin{funcdesc}{grey2mono}{image\, width\, height\, threshold}
47 This function converts a 8-bit deep greyscale image to a 1-bit deep
48 image by tresholding all the pixels. The resulting image is tightly
49 packed and is probably only useful as an argument to \code{mono2grey}.
50 \end{funcdesc}
52 \begin{funcdesc}{dither2mono}{image\, width\, height}
53 This function also converts an 8-bit greyscale image to a 1-bit
54 monochrome image but it uses a (simple-minded) dithering algorithm.
55 \end{funcdesc}
57 \begin{funcdesc}{mono2grey}{image\, width\, height\, p0\, p1}
58 This function converts a 1-bit monochrome image to an 8 bit greyscale
59 or color image. All pixels that are zero-valued on input get value
60 \code{p0} on output and all one-value input pixels get value \code{p1}
61 on output. To convert a monochrome black-and-white image to greyscale
62 pass the values \code{0} and \code{255} respectively.
63 \end{funcdesc}
65 \begin{funcdesc}{grey2grey4}{image\, width\, height}
66 Convert an 8-bit greyscale image to a 4-bit greyscale image without
67 dithering.
68 \end{funcdesc}
70 \begin{funcdesc}{grey2grey2}{image\, width\, height}
71 Convert an 8-bit greyscale image to a 2-bit greyscale image without
72 dithering.
73 \end{funcdesc}
75 \begin{funcdesc}{dither2grey2}{image\, width\, height}
76 Convert an 8-bit greyscale image to a 2-bit greyscale image with
77 dithering. As for \code{dither2mono}, the dithering algorithm is
78 currently very simple.
79 \end{funcdesc}
81 \begin{funcdesc}{grey42grey}{image\, width\, height}
82 Convert a 4-bit greyscale image to an 8-bit greyscale image.
83 \end{funcdesc}
85 \begin{funcdesc}{grey22grey}{image\, width\, height}
86 Convert a 2-bit greyscale image to an 8-bit greyscale image.
87 \end{funcdesc}