Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / doc / html / _sources / design / basics.rst.txt
1 Basics
2 ======
3
4 Images are essential in any image processing, vision and video project, and
5 yet the variability in image representations makes it difficult to write
6 imaging algorithms that are both generic and efficient. In this section we
7 will describe some of the challenges that we would like to address.
8
9 In the following discussion an *image* is a 2D array of pixels. A *pixel* is a
10 set of color channels that represents the color at a given point in an image.
11 Each *channel* represents the value of a color component. There are two common
12 memory structures for an image. *Interleaved* images are represented by
13 grouping the pixels together in memory and interleaving all channels together,
14 whereas *planar* images keep the channels in separate color planes. Here is a
15 4x3 RGB image in which the second pixel of the first row is marked in red,
16 in interleaved form:
17
18 .. image:: ../images/interleaved.jpg
19
20 and in planar form:
21
22 .. image:: ../images/planar.jpg
23
24 Note also that rows may optionally be aligned resulting in a potential padding
25 at the end of rows.
26
27 The Generic Image Library (GIL) provides models for images that vary in:
28
29 * Structure (planar vs. interleaved)
30 * Color space and presence of alpha (RGB, RGBA, CMYK, etc.)
31 * Channel depth (8-bit, 16-bit, etc.)
32 * Order of channels (RGB vs. BGR, etc.)
33 * Row alignment policy (no alignment, word-alignment, etc.)
34
35 It also supports user-defined models of images, and images whose parameters
36 are specified at run-time. GIL abstracts image representation from algorithms
37 applied on images and allows us to write the algorithm once and have it work
38 on any of the above image variations while generating code that is comparable
39 in speed to that of hand-writing the algorithm for a specific image type.
40
41 This document follows bottom-up design. Each section defines concepts that
42 build on top of concepts defined in previous sections. It is recommended to
43 read the sections in order.