|
enum | { COLOR_RED = 0
, COLOR_GREEN = 1
, COLOR_BLUE = 2
, L_ALPHA_CHANNEL = 3
} |
|
enum | {
L_DRAW_RED = 0
, L_DRAW_GREEN = 1
, L_DRAW_BLUE = 2
, L_DRAW_SPECIFIED = 3
,
L_DRAW_RGB = 4
, L_DRAW_RANDOM = 5
} |
|
enum | {
REMOVE_CMAP_TO_BINARY = 0
, REMOVE_CMAP_TO_GRAYSCALE = 1
, REMOVE_CMAP_TO_FULL_COLOR = 2
, REMOVE_CMAP_WITH_ALPHA = 3
,
REMOVE_CMAP_BASED_ON_SRC = 4
} |
|
enum | {
L_NOCOPY = 0
, L_INSERT = L_NOCOPY
, L_COPY = 1
, L_CLONE = 2
,
L_COPY_CLONE = 3
} |
|
enum | { L_SHELL_SORT = 1
, L_BIN_SORT = 2
} |
|
enum | { L_SORT_INCREASING = 1
, L_SORT_DECREASING = 2
} |
|
enum | {
L_SORT_BY_X = 1
, L_SORT_BY_Y = 2
, L_SORT_BY_RIGHT = 3
, L_SORT_BY_BOT = 4
,
L_SORT_BY_WIDTH = 5
, L_SORT_BY_HEIGHT = 6
, L_SORT_BY_MIN_DIMENSION = 7
, L_SORT_BY_MAX_DIMENSION = 8
,
L_SORT_BY_PERIMETER = 9
, L_SORT_BY_AREA = 10
, L_SORT_BY_ASPECT_RATIO = 11
} |
|
enum | {
L_BLEND_WITH_INVERSE = 1
, L_BLEND_TO_WHITE = 2
, L_BLEND_TO_BLACK = 3
, L_BLEND_GRAY = 4
,
L_BLEND_GRAY_WITH_INVERSE = 5
} |
|
enum | { L_PAINT_LIGHT = 1
, L_PAINT_DARK = 2
} |
|
enum | { L_SET_PIXELS = 1
, L_CLEAR_PIXELS = 2
, L_FLIP_PIXELS = 3
} |
|
enum | { L_SELECT_IF_LT = 1
, L_SELECT_IF_GT = 2
, L_SELECT_IF_LTE = 3
, L_SELECT_IF_GTE = 4
} |
|
enum | {
L_SELECT_BY_WIDTH = 1
, L_SELECT_BY_HEIGHT = 2
, L_SELECT_BY_MAX_DIMENSION = 3
, L_SELECT_BY_AREA = 4
,
L_SELECT_BY_PERIMETER = 5
} |
|
enum | {
L_SELECT_WIDTH = 1
, L_SELECT_HEIGHT = 2
, L_SELECT_XVAL = 3
, L_SELECT_YVAL = 4
,
L_SELECT_IF_EITHER = 5
, L_SELECT_IF_BOTH = 6
} |
|
enum | { L_CHECK_WIDTH = 1
, L_CHECK_HEIGHT = 2
, L_CHECK_BOTH = 3
} |
|
enum | {
L_SELECT_RED = 1
, L_SELECT_GREEN = 2
, L_SELECT_BLUE = 3
, L_SELECT_MIN = 4
,
L_SELECT_MAX = 5
, L_SELECT_AVERAGE = 6
, L_SELECT_HUE = 7
, L_SELECT_SATURATION = 8
,
L_SELECT_WEIGHTED = 9
} |
|
enum | { L_INTERMED_DIFF = 1
, L_AVE_MAX_DIFF_2 = 2
, L_MAX_DIFF = 3
} |
|
enum | {
L_LS_BYTE = 1
, L_MS_BYTE = 2
, L_AUTO_BYTE = 3
, L_CLIP_TO_FF = 4
,
L_LS_TWO_BYTES = 5
, L_MS_TWO_BYTES = 6
, L_CLIP_TO_FFFF = 7
} |
|
enum | { L_ROTATE_AREA_MAP = 1
, L_ROTATE_SHEAR = 2
, L_ROTATE_SAMPLING = 3
} |
|
enum | { L_BRING_IN_WHITE = 1
, L_BRING_IN_BLACK = 2
} |
|
enum | { L_SHEAR_ABOUT_CORNER = 1
, L_SHEAR_ABOUT_CENTER = 2
} |
|
enum | {
L_TR_SC_RO = 1
, L_SC_RO_TR = 2
, L_RO_TR_SC = 3
, L_TR_RO_SC = 4
,
L_RO_SC_TR = 5
, L_SC_TR_RO = 6
} |
|
enum | { L_FILL_WHITE = 1
, L_FILL_BLACK = 2
} |
|
enum | { L_SET_WHITE = 1
, L_SET_BLACK = 2
} |
|
enum | { L_GET_WHITE_VAL = 1
, L_GET_BLACK_VAL = 2
} |
|
enum | { L_WHITE_IS_MAX = 1
, L_BLACK_IS_MAX = 2
} |
|
enum | { DEFAULT_CLIP_LOWER_1 = 10
, DEFAULT_CLIP_UPPER_1 = 10
, DEFAULT_CLIP_LOWER_2 = 5
, DEFAULT_CLIP_UPPER_2 = 5
} |
|
enum | { L_MANHATTAN_DISTANCE = 1
, L_EUCLIDEAN_DISTANCE = 2
} |
|
enum | {
L_NEGATIVE = 1
, L_NON_NEGATIVE = 2
, L_POSITIVE = 3
, L_NON_POSITIVE = 4
,
L_ZERO = 5
, L_ALL = 6
} |
|
enum | {
L_MEAN_ABSVAL = 1
, L_MEDIAN_VAL = 2
, L_MODE_VAL = 3
, L_MODE_COUNT = 4
,
L_ROOT_MEAN_SQUARE = 5
, L_STANDARD_DEVIATION = 6
, L_VARIANCE = 7
} |
|
enum | { L_CHOOSE_CONSECUTIVE = 1
, L_CHOOSE_SKIP_BY = 2
} |
|
enum | {
L_TEXT_ORIENT_UNKNOWN = 0
, L_TEXT_ORIENT_UP = 1
, L_TEXT_ORIENT_LEFT = 2
, L_TEXT_ORIENT_DOWN = 3
,
L_TEXT_ORIENT_RIGHT = 4
} |
|
enum | { L_HORIZONTAL_EDGES = 0
, L_VERTICAL_EDGES = 1
, L_ALL_EDGES = 2
} |
|
enum | {
L_HORIZONTAL_LINE = 0
, L_POS_SLOPE_LINE = 1
, L_VERTICAL_LINE = 2
, L_NEG_SLOPE_LINE = 3
,
L_OBLIQUE_LINE = 4
} |
|
enum | { L_PORTRAIT_MODE = 0
, L_LANDSCAPE_MODE = 1
} |
|
enum | {
L_FROM_LEFT = 0
, L_FROM_RIGHT = 1
, L_FROM_TOP = 2
, L_FROM_BOT = 3
,
L_SCAN_NEGATIVE = 4
, L_SCAN_POSITIVE = 5
, L_SCAN_BOTH = 6
, L_SCAN_HORIZONTAL = 7
,
L_SCAN_VERTICAL = 8
} |
|
enum | {
L_ADJUST_SKIP = 0
, L_ADJUST_LEFT = 1
, L_ADJUST_RIGHT = 2
, L_ADJUST_LEFT_AND_RIGHT = 3
,
L_ADJUST_TOP = 4
, L_ADJUST_BOT = 5
, L_ADJUST_TOP_AND_BOT = 6
, L_ADJUST_CHOOSE_MIN = 7
,
L_ADJUST_CHOOSE_MAX = 8
, L_SET_LEFT = 9
, L_SET_RIGHT = 10
, L_SET_TOP = 11
,
L_SET_BOT = 12
, L_GET_LEFT = 13
, L_GET_RIGHT = 14
, L_GET_TOP = 15
,
L_GET_BOT = 16
} |
|
enum | {
L_USE_MINSIZE = 1
, L_USE_MAXSIZE = 2
, L_SUB_ON_LOC_DIFF = 3
, L_SUB_ON_SIZE_DIFF = 4
,
L_USE_CAPPED_MIN = 5
, L_USE_CAPPED_MAX = 6
} |
|
enum | { L_COMBINE = 1
, L_REMOVE_SMALL = 2
} |
|
enum | { L_GEOMETRIC_UNION = 1
, L_GEOMETRIC_INTERSECTION = 2
, L_LARGEST_AREA = 3
, L_SMALLEST_AREA = 4
} |
|
enum | { L_USE_ALL_BOXES = 1
, L_USE_SAME_PARITY_BOXES = 2
} |
|
enum | {
L_UPPER_LEFT = 1
, L_UPPER_RIGHT = 2
, L_LOWER_LEFT = 3
, L_LOWER_RIGHT = 4
,
L_BOX_CENTER = 5
} |
|
enum | { L_WARP_TO_LEFT = 1
, L_WARP_TO_RIGHT = 2
} |
|
enum | { L_LINEAR_WARP = 1
, L_QUADRATIC_WARP = 2
} |
|
enum | { L_INTERPOLATED = 1
, L_SAMPLED = 2
} |
|
enum | { L_THIN_FG = 1
, L_THIN_BG = 2
} |
|
enum | { L_HORIZONTAL_RUNS = 0
, L_VERTICAL_RUNS = 1
} |
|
enum | { L_SOBEL_EDGE = 1
, L_TWO_SIDED_EDGE = 2
} |
|
enum | { L_SUBPIXEL_ORDER_RGB = 1
, L_SUBPIXEL_ORDER_BGR = 2
, L_SUBPIXEL_ORDER_VRGB = 3
, L_SUBPIXEL_ORDER_VBGR = 4
} |
|
enum | { L_HS_HISTO = 1
, L_HV_HISTO = 2
, L_SV_HISTO = 3
} |
|
enum | { L_INCLUDE_REGION = 1
, L_EXCLUDE_REGION = 2
} |
|
enum | {
L_ADD_ABOVE = 1
, L_ADD_BELOW = 2
, L_ADD_LEFT = 3
, L_ADD_RIGHT = 4
,
L_ADD_AT_TOP = 5
, L_ADD_AT_BOT = 6
, L_ADD_AT_LEFT = 7
, L_ADD_AT_RIGHT = 8
} |
|
enum | {
L_PLOT_AT_TOP = 1
, L_PLOT_AT_MID_HORIZ = 2
, L_PLOT_AT_BOT = 3
, L_PLOT_AT_LEFT = 4
,
L_PLOT_AT_MID_VERT = 5
, L_PLOT_AT_RIGHT = 6
} |
|
enum | { L_USE_INNER = 1
, L_USE_OUTER = 2
} |
|
enum | {
L_DISPLAY_WITH_XZGV = 1
, L_DISPLAY_WITH_XLI = 2
, L_DISPLAY_WITH_XV = 3
, L_DISPLAY_WITH_IV = 4
,
L_DISPLAY_WITH_OPEN = 5
} |
|
enum | { L_NO_CHROMA_SAMPLING_JPEG = 1
} |
|
enum | { L_CLIP_TO_ZERO = 1
, L_TAKE_ABSVAL = 2
} |
|
enum | { L_LESS_THAN_ZERO = 1
, L_EQUAL_TO_ZERO = 2
, L_GREATER_THAN_ZERO = 3
} |
|
enum | { L_ADD_TRAIL_SLASH = 1
, L_REMOVE_TRAIL_SLASH = 2
} |
|
Valid image types in leptonica:
Pix: 1 bpp, with and without colormap
Pix: 2 bpp, with and without colormap
Pix: 4 bpp, with and without colormap
Pix: 8 bpp, with and without colormap
Pix: 16 bpp (1 spp)
Pix: 32 bpp (rgb, 3 spp)
Pix: 32 bpp (rgba, 4 spp)
FPix: 32 bpp float
DPix: 64 bpp double
Notes:
(1) The only valid Pix image type with alpha is rgba.
In particular, the alpha component is not used in
cmapped images.
(2) PixComp can hold any Pix with IFF_PNG encoding.
Contents:
(1) This file has typedefs for most of the image-related structs
used in leptonica:
struct Pix
struct PixColormap
struct RGBA_Quad
struct Pixa
struct Pixaa
struct Box
struct Boxa
struct Boxaa
struct Pta
struct Ptaa
struct Pixacc
struct PixTiling
struct FPix
struct FPixa
struct DPix
struct PixComp
struct PixaComp
(2) This file has definitions for:
Colors for RGBA
Colors for drawing boxes
Perceptual color weights
Colormap conversion flags
Rasterop bit flags
Structure access flags (for insert, copy, clone, copy-clone)
Sorting flags (by type and direction)
Blending flags
Graphics pixel setting flags
Size and location filter flags
Color component selection flags
Color content flags
16-bit conversion flags
Rotation and shear flags
Affine transform order flags
Grayscale filling flags
Flags for setting to white or black
Flags for getting white or black pixel value
Flags for 8 and 16 bit pixel sums
Dithering flags
Distance flags
Value flags
Statistical measures
Set selection flags
Text orientation flags
Edge orientation flags
Line orientation flags
Image orientation flags
Scan direction flags
Box size adjustment flags
Flags for modifying box boundaries using a second box
Handling overlapping bounding boxes in boxa
Selecting or making a box from two (intersecting) boxes
Flags for replacing invalid boxes
Flags for box corners and center
Horizontal warp
Pixel selection for resampling
Thinning flags
Runlength flags
Edge filter flags
Subpixel color component ordering in LCD display
HSV histogram flags
Region flags (inclusion, exclusion)
Flags for adding text to a pix
Flags for plotting on a pix
Flags for making simple masks
Flags for selecting display program
Flags in the 'special' pix field for non-default operations
Handling negative values in conversion to unsigned int
Relative to zero flags
Flags for adding or removing trailing slash from string
(3) This file has typedefs for the pix allocator and deallocator functions
alloc_fn()
dealloc_fn().
-------------------------------------------------------------------
Notes on the pixels in the raster image. This information can also
be found in pix_internal.h.
(1) The image data is stored in a single contiguous
array of l_uint32, into which the pixels are packed.
By "packed" we mean that there are no unused bits
between pixels, except for end-of-line padding to
satisfy item (2) below.
(2) Every image raster line begins on a 32-bit word
boundary within this array.
(3) Pix image data is stored in 32-bit units, with the
pixels ordered from left to right in the image being
stored in order from the MSB to LSB within the word,
for both big-endian and little-endian machines.
This is the natural ordering for big-endian machines,
as successive bytes are stored and fetched progressively
to the right. However, for little-endians, when storing
we re-order the bytes from this byte stream order, and
reshuffle again for byte access on 32-bit entities.
So if the bytes come in sequence from left to right, we
store them on little-endians in byte order:
3 2 1 0 7 6 5 4 ...
This MSB to LSB ordering allows left and right shift
operations on 32 bit words to move the pixels properly.
(4) We use 32 bit pixels for both RGB and RGBA color images.
The A (alpha) byte is ignored in most leptonica functions
operating on color images. Within each 4 byte pixel, the
color samples are ordered from MSB to LSB, as follows:
| MSB | 2nd MSB | 3rd MSB | LSB |
red green blue alpha
0 1 2 3 (big-endian)
3 2 1 0 (little-endian)
Because we use MSB to LSB ordering within the 32-bit word,
the individual 8-bit samples can be accessed with
GET_DATA_BYTE and SET_DATA_BYTE macros, using the
(implicitly big-ending) ordering
red: byte 0 (MSB)
green: byte 1 (2nd MSB)
blue: byte 2 (3rd MSB)
alpha: byte 3 (LSB)
The specific color assignment is made in this file,
through the definitions of COLOR_RED, etc. Then the R, G
B and A sample values can be retrieved using
redval = GET_DATA_BYTE(&pixel, COLOR_RED);
greenval = GET_DATA_BYTE(&pixel, COLOR_GREEN);
blueval = GET_DATA_BYTE(&pixel, COLOR_BLUE);
alphaval = GET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL);
and they can be set with
SET_DATA_BYTE(&pixel, COLOR_RED, redval);
SET_DATA_BYTE(&pixel, COLOR_GREEN, greenval);
SET_DATA_BYTE(&pixel, COLOR_BLUE, blueval);
SET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL, alphaval);
More efficiently, these components can be extracted directly
by shifting and masking, explicitly using the values in
L_RED_SHIFT, etc.:
(pixel32 >> L_RED_SHIFT) & 0xff; (red)
(pixel32 >> L_GREEN_SHIFT) & 0xff; (green)
(pixel32 >> L_BLUE_SHIFT) & 0xff; (blue)
(pixel32 >> L_ALPHA_SHIFT) & 0xff; (alpha)
The functions extractRGBValues() and extractRGBAValues() are
provided to do this. Likewise, the pixels can be set
directly by shifting, using composeRGBPixel() and
composeRGBAPixel().
All these operations work properly on both big- and little-endians.
(5) A reference count is held within each pix, giving the
number of ptrs to the pix. When a pixClone() call
is made, the ref count is increased by 1, and
when a pixDestroy() call is made, the reference count
of the pix is decremented. The pix is only destroyed
when the reference count goes to zero.
(6) Version numbers are used in the serialization of image-related
data structures. They are placed in the files, and rarely
(if ever) change.
(7) The serialization dependencies are as follows:
pixaa : pixa : boxa
boxaa : boxa
So, for example, pixaa and boxaa can be changed without
forcing a change in pixa or boxa. However, if pixa is
changed, it forces a change in pixaa, and if boxa is
changed, if forces a change in the other three.
Definition in file pix.h.