f | |
| :mod:`imageop` --- Manipulate raw image data |
| ============================================ |
| |
| .. module:: imageop |
| :synopsis: Manipulate raw image data. |
n | :deprecated: |
| |
n | .. deprecated:: 2.6 |
| The :mod:`imageop` module has been removed in Python 3.0. |
| |
| The :mod:`imageop` module contains some useful operations on images. It operates |
| on images consisting of 8 or 32 bit pixels stored in Python strings. This is |
| the same format as used by :func:`gl.lrectwrite` and the :mod:`imgfile` module. |
| |
| The module defines the following variables and functions: |
| |
| |
| .. exception:: error |
| |
| This exception is raised on all errors, such as unknown number of bits per |
| pixel, etc. |
| |
| |
| .. function:: crop(image, psize, width, height, x0, y0, x1, y1) |
| |
n | Return the selected part of *image*, which should by *width* by *height* in size |
n | Return the selected part of *image*, which should be *width* by *height* in size |
| and consist of pixels of *psize* bytes. *x0*, *y0*, *x1* and *y1* are like the |
| :func:`gl.lrectread` parameters, i.e. the boundary is included in the new image. |
| The new boundaries need not be inside the picture. Pixels that fall outside the |
| old image will have their value set to zero. If *x0* is bigger than *x1* the |
| new image is mirrored. The same holds for the y coordinates. |
| |
| |
| .. function:: scale(image, psize, width, height, newwidth, newheight) |
| |
| Convert a 8-bit deep greyscale image to a 1-bit deep image by thresholding all |
| the pixels. The resulting image is tightly packed and is probably only useful |
| as an argument to :func:`mono2grey`. |
| |
| |
| .. function:: dither2mono(image, width, height) |
| |
n | Convert an 8-bit greyscale image to a 1-bit monochrome image using a (simple- |
n | Convert an 8-bit greyscale image to a 1-bit monochrome image using a |
| minded) dithering algorithm. |
| (simple-minded) dithering algorithm. |
| |
| |
| .. function:: mono2grey(image, width, height, p0, p1) |
| |
| Convert a 1-bit monochrome image to an 8 bit greyscale or color image. All |
| pixels that are zero-valued on input get value *p0* on output and all one-value |
| input pixels get value *p1* on output. To convert a monochrome black-and-white |
| image to greyscale pass the values ``0`` and ``255`` respectively. |
| |
| .. function:: grey22grey(image, width, height) |
| |
| Convert a 2-bit greyscale image to an 8-bit greyscale image. |
| |
| |
| .. data:: backward_compatible |
| |
t | If set to 0, the functions in this module use a non-backward compatible way of |
t | If set to 0, the functions in this module use a non-backward compatible way |
| representing multi-byte pixels on little-endian systems. The SGI for which this |
| of representing multi-byte pixels on little-endian systems. The SGI for |
| module was originally written is a big-endian system, so setting this variable |
| which this module was originally written is a big-endian system, so setting |
| will have no effect. However, the code wasn't originally intended to run on |
| this variable will have no effect. However, the code wasn't originally |
| anything else, so it made assumptions about byte order which are not universal. |
| intended to run on anything else, so it made assumptions about byte order |
| Setting this variable to 0 will cause the byte order to be reversed on little- |
| which are not universal. Setting this variable to 0 will cause the byte |
| endian systems, so that it then is the same as on big-endian systems. |
| order to be reversed on little-endian systems, so that it then is the same as |
| on big-endian systems. |
| |