Leptonica 1.68
C Image Processing Library
|
00001 /*====================================================================* 00002 - Copyright (C) 2001 Leptonica. All rights reserved. 00003 - This software is distributed in the hope that it will be 00004 - useful, but with NO WARRANTY OF ANY KIND. 00005 - No author or distributor accepts responsibility to anyone for the 00006 - consequences of using this software, or for whether it serves any 00007 - particular purpose or works at all, unless he or she says so in 00008 - writing. Everyone is granted permission to copy, modify and 00009 - redistribute this source code, for commercial or non-commercial 00010 - purposes, with the following restrictions: (1) the origin of this 00011 - source code must not be misrepresented; (2) modified versions must 00012 - be plainly marked as such; and (3) this notice may not be removed 00013 - or altered from any source or modified source distribution. 00014 *====================================================================*/ 00015 00016 #ifndef LEPTONICA_PIX_H 00017 #define LEPTONICA_PIX_H 00018 00019 /* 00020 * pix.h 00021 * 00022 * Contains the following structures: 00023 * struct Pix 00024 * struct PixColormap 00025 * struct RGBA_Quad 00026 * struct Pixa 00027 * struct Pixaa 00028 * struct Box 00029 * struct Boxa 00030 * struct Boxaa 00031 * struct Pta 00032 * struct Ptaa 00033 * struct Pixacc 00034 * struct PixTiling 00035 * struct FPix 00036 * struct FPixa 00037 * struct DPix 00038 * struct PixComp 00039 * struct PixaComp 00040 * 00041 * Contains definitions for: 00042 * Colors for RGB 00043 * Perceptual color weights 00044 * Colormap conversion flags 00045 * Rasterop bit flags 00046 * Structure access flags (for insert, copy, clone, copy-clone) 00047 * Sorting flags (by type and direction) 00048 * Blending flags 00049 * Graphics pixel setting flags 00050 * Size filtering flags 00051 * Color component selection flags 00052 * Rotation and shear flags 00053 * Affine transform order flags 00054 * Grayscale filling flags 00055 * Flags for setting to white or black 00056 * Dithering flags 00057 * Distance flags 00058 * Statistical measures 00059 * Set selection flags 00060 * Text orientation flags 00061 * Edge orientation flags 00062 * Line orientation flags 00063 * Scan direction flags 00064 * Horizontal warp 00065 * Pixel selection for resampling 00066 * Thinning flags 00067 * Runlength flags 00068 * Edge filter flags 00069 * Handling negative values in conversion to unsigned int 00070 * Subpixel color component ordering in LCD display 00071 * Relative to zero flags 00072 * HSV histogram flags 00073 * Region flags (inclusion, exclusion) 00074 * Flags for adding text to a pix 00075 * Flags for selecting display program 00076 */ 00077 00078 00079 /*-------------------------------------------------------------------------* 00080 * Basic Pix * 00081 *-------------------------------------------------------------------------*/ 00082 struct Pix 00083 { 00084 l_uint32 w; /* width in pixels */ 00085 l_uint32 h; /* height in pixels */ 00086 l_uint32 d; /* depth in bits */ 00087 l_uint32 wpl; /* 32-bit words/line */ 00088 l_uint32 refcount; /* reference count (1 if no clones) */ 00089 l_int32 xres; /* image res (ppi) in x direction */ 00090 /* (use 0 if unknown) */ 00091 l_int32 yres; /* image res (ppi) in y direction */ 00092 /* (use 0 if unknown) */ 00093 l_int32 informat; /* input file format, IFF_* */ 00094 char *text; /* text string associated with pix */ 00095 struct PixColormap *colormap; /* colormap (may be null) */ 00096 l_uint32 *data; /* the image data */ 00097 }; 00098 typedef struct Pix PIX; 00099 00100 00101 struct PixColormap 00102 { 00103 void *array; /* colormap table (array of RGBA_QUAD) */ 00104 l_int32 depth; /* of pix (1, 2, 4 or 8 bpp) */ 00105 l_int32 nalloc; /* number of color entries allocated */ 00106 l_int32 n; /* number of color entries used */ 00107 }; 00108 typedef struct PixColormap PIXCMAP; 00109 00110 00111 /* Colormap table entry (after the BMP version). 00112 * Note that the BMP format stores the colormap table exactly 00113 * as it appears here, with color samples being stored sequentially, 00114 * in the order (b,g,r,a). */ 00115 struct RGBA_Quad 00116 { 00117 l_uint8 blue; 00118 l_uint8 green; 00119 l_uint8 red; 00120 l_uint8 reserved; 00121 }; 00122 typedef struct RGBA_Quad RGBA_QUAD; 00123 00124 00125 00126 /*-------------------------------------------------------------------------* 00127 * Colors for 32 bpp * 00128 *-------------------------------------------------------------------------*/ 00129 /* Notes: 00130 * (1) These are the byte indices for colors in 32 bpp images. 00131 * They are used through the GET/SET_DATA_BYTE accessors. 00132 * The 4th byte, typically known as the "alpha channel" and used 00133 * for blending, is not explicitly used in leptonica. 00134 * (2) If you redefine these values, functions that have the shifts 00135 * hardcoded (instead of using the constants below) will break. 00136 * These functions are labelled with "***" next to their names 00137 * at the top of the files in which they are defined. 00138 * Advice: Do not change these values! 00139 * (3) The shifts to extract the red, green and blue components 00140 * from a 32 bit pixel are defined in terms of these colors. 00141 */ 00142 enum { 00143 COLOR_RED = 0, 00144 COLOR_GREEN = 1, 00145 COLOR_BLUE = 2, 00146 L_ALPHA_CHANNEL = 3 00147 }; 00148 00149 static const l_int32 L_RED_SHIFT = 00150 8 * (sizeof(l_uint32) - 1 - COLOR_RED); /* 24 */ 00151 static const l_int32 L_GREEN_SHIFT = 00152 8 * (sizeof(l_uint32) - 1 - COLOR_GREEN); /* 16 */ 00153 static const l_int32 L_BLUE_SHIFT = 00154 8 * (sizeof(l_uint32) - 1 - COLOR_BLUE); /* 8 */ 00155 static const l_int32 L_ALPHA_SHIFT = 00156 8 * (sizeof(l_uint32) - 1 - L_ALPHA_CHANNEL); /* 0 */ 00157 00158 00159 /*-------------------------------------------------------------------------* 00160 * Perceptual color weights * 00161 *-------------------------------------------------------------------------*/ 00162 /* Notes: 00163 * (1) These numbers are ad-hoc, but they do add up to 1. 00164 * Unlike, for example, the weighting factor for conversion 00165 * of RGB to luminance, or more specifically to Y in the 00166 * YUV colorspace. Those numbers come from the 00167 * International Telecommunications Union, via ITU-R. 00168 */ 00169 static const l_float32 L_RED_WEIGHT = 0.3; 00170 static const l_float32 L_GREEN_WEIGHT = 0.5; 00171 static const l_float32 L_BLUE_WEIGHT = 0.2; 00172 00173 00174 /*-------------------------------------------------------------------------* 00175 * Flags for colormap conversion * 00176 *-------------------------------------------------------------------------*/ 00177 enum { 00178 REMOVE_CMAP_TO_BINARY = 0, 00179 REMOVE_CMAP_TO_GRAYSCALE = 1, 00180 REMOVE_CMAP_TO_FULL_COLOR = 2, 00181 REMOVE_CMAP_BASED_ON_SRC = 3 00182 }; 00183 00184 00185 /*-------------------------------------------------------------------------* 00186 * 00187 * The following operation bit flags have been modified from 00188 * Sun's pixrect.h. 00189 * 00190 * The 'op' in 'rasterop' is represented by an integer 00191 * composed with Boolean functions using the set of five integers 00192 * given below. The integers, and the op codes resulting from 00193 * boolean expressions on them, need only be in the range from 0 to 15. 00194 * The function is applied on a per-pixel basis. 00195 * 00196 * Examples: the op code representing ORing the src and dest 00197 * is computed using the bit OR, as PIX_SRC | PIX_DST; the op 00198 * code representing XORing src and dest is found from 00199 * PIX_SRC ^ PIX_DST; the op code representing ANDing src and dest 00200 * is found from PIX_SRC & PIX_DST. Note that 00201 * PIX_NOT(PIX_CLR) = PIX_SET, and v.v., as they must be. 00202 * 00203 * We would like to use the following set of definitions: 00204 * 00205 * #define PIX_SRC 0xc 00206 * #define PIX_DST 0xa 00207 * #define PIX_NOT(op) ((op) ^ 0xf) 00208 * #define PIX_CLR 0x0 00209 * #define PIX_SET 0xf 00210 * 00211 * Now, these definitions differ from Sun's, in that Sun 00212 * left-shifted each value by 1 pixel, and used the least 00213 * significant bit as a flag for the "pseudo-operation" of 00214 * clipping. We don't need this bit, because it is both 00215 * efficient and safe ALWAYS to clip the rectangles to the src 00216 * and dest images, which is what we do. See the notes in rop.h 00217 * on the general choice of these bit flags. 00218 * 00219 * However, if you include Sun's xview package, you will get their 00220 * definitions, and because I like using these flags, we will 00221 * adopt the original Sun definitions to avoid redefinition conflicts. 00222 * 00223 * Then we have, for reference, the following 16 unique op flags: 00224 * 00225 * PIX_CLR 00000 0x0 00226 * PIX_SET 11110 0x1e 00227 * PIX_SRC 11000 0x18 00228 * PIX_DST 10100 0x14 00229 * PIX_NOT(PIX_SRC) 00110 0x06 00230 * PIX_NOT(PIX_DST) 01010 0x0a 00231 * PIX_SRC | PIX_DST 11100 0x1c 00232 * PIX_SRC & PIX_DST 10000 0x10 00233 * PIX_SRC ^ PIX_DST 01100 0x0c 00234 * PIX_NOT(PIX_SRC) | PIX_DST 10110 0x16 00235 * PIX_NOT(PIX_SRC) & PIX_DST 00100 0x04 00236 * PIX_SRC | PIX_NOT(PIX_DST) 11010 0x1a 00237 * PIX_SRC & PIX_NOT(PIX_DST) 01000 0x08 00238 * PIX_NOT(PIX_SRC | PIX_DST) 00010 0x02 00239 * PIX_NOT(PIX_SRC & PIX_DST) 01110 0x0e 00240 * PIX_NOT(PIX_SRC ^ PIX_DST) 10010 0x12 00241 * 00242 *-------------------------------------------------------------------------*/ 00243 #define PIX_SRC (0xc << 1) 00244 #define PIX_DST (0xa << 1) 00245 #define PIX_NOT(op) ((op) ^ 0x1e) 00246 #define PIX_CLR (0x0 << 1) 00247 #define PIX_SET (0xf << 1) 00248 00249 #define PIX_PAINT (PIX_SRC | PIX_DST) 00250 #define PIX_MASK (PIX_SRC & PIX_DST) 00251 #define PIX_SUBTRACT (PIX_DST & PIX_NOT(PIX_SRC)) 00252 #define PIX_XOR (PIX_SRC ^ PIX_DST) 00253 00254 00255 /*-------------------------------------------------------------------------* 00256 * 00257 * Important Notes: 00258 * 00259 * (1) The image data is stored in a single contiguous 00260 * array of l_uint32, into which the pixels are packed. 00261 * By "packed" we mean that there are no unused bits 00262 * between pixels, except for end-of-line padding to 00263 * satisfy item (2) below. 00264 * 00265 * (2) Every image raster line begins on a 32-bit word 00266 * boundary within this array. 00267 * 00268 * (3) Pix image data is stored in 32-bit units, with the 00269 * pixels ordered from left to right in the image being 00270 * stored in order from the MSB to LSB within the word, 00271 * for both big-endian and little-endian machines. 00272 * This is the natural ordering for big-endian machines, 00273 * as successive bytes are stored and fetched progressively 00274 * to the right. However, for little-endians, when storing 00275 * we re-order the bytes from this byte stream order, and 00276 * reshuffle again for byte access on 32-bit entities. 00277 * So if the bytes come in sequence from left to right, we 00278 * store them on little-endians in byte order: 00279 * 3 2 1 0 7 6 5 4 ... 00280 * This MSB to LSB ordering allows left and right shift 00281 * operations on 32 bit words to move the pixels properly. 00282 * 00283 * (4) For 24-bit color images, use 32 bpp data, leaving 00284 * the fourth byte unused. Within each 4 byte pixel, the 00285 * colors are ordered from MSB to LSB, as follows: 00286 * 00287 * | MSB | 2nd MSB | 3rd MSB | LSB | 00288 * red green blue unused 00289 * 0 1 2 3 (big-endian) 00290 * 3 2 1 0 (little-endian) 00291 * 00292 * Because we use MSB to LSB ordering within the 32-bit word, 00293 * the individual 8-bit samples can be accessed with 00294 * GET_DATA_BYTE and SET_DATA_BYTE macros, using the 00295 * (implicitly big-ending) ordering 00296 * red: byte 0 (MSB) 00297 * green: byte 1 (2nd MSB) 00298 * blue: byte 2 (3rd MSB) 00299 * 00300 * This specific color assignment is made in this file, 00301 * through the definitions of COLOR_RED, etc. Then the R, G 00302 * and B sample values can be retrieved using 00303 * redval = GET_DATA_BYTE(&pixel, COLOR_RED); 00304 * greenval = GET_DATA_BYTE(&pixel, COLOR_GREEN); 00305 * blueval = GET_DATA_BYTE(&pixel, COLOR_BLUE); 00306 * and they can be set with 00307 * SET_DATA_BYTE(&pixel, COLOR_RED, redval); 00308 * SET_DATA_BYTE(&pixel, COLOR_GREEN, greenval); 00309 * SET_DATA_BYTE(&pixel, COLOR_BLUE, blueval); 00310 * 00311 * For extra speed we extract the R, G and B colors directly 00312 * by shifting and masking, explicitly using the values in 00313 * L_RED_SHIFT, L_GREEN_SHIFT and L_BLUE_SHIFT: 00314 * (pixel32 >> L_RED_SHIFT) & 0xff; (red) 00315 * (pixel32 >> L_GREEN_SHIFT) & 0xff; (green) 00316 * (pixel32 >> L_BLUE_SHIFT) & 0xff; (blue) 00317 * All these operations work properly on both big- and little-endians. 00318 * 00319 * For a few situations, these color shift values are hard-coded. 00320 * Changing the RGB color component ordering through the assignments 00321 * in this file will cause functions marked with "***" to fail. 00322 * 00323 * (5) A reference count is held within each pix, giving the 00324 * number of ptrs to the pix. When a pixClone() call 00325 * is made, the ref count is increased by 1, and 00326 * when a pixDestroy() call is made, the reference count 00327 * of the pix is decremented. The pix is only destroyed 00328 * when the reference count goes to zero. 00329 * 00330 * (6) The version numbers (below) are used in the serialization 00331 * of these data structures. They are placed in the files, 00332 * and rarely (if ever) change. Provision is currently made for 00333 * backward compatibility in reading from boxaa version 2. 00334 * 00335 * (7) The serialization dependencies are as follows: 00336 * pixaa : pixa : boxa 00337 * boxaa : boxa 00338 * So, for example, pixaa and boxaa can be changed without 00339 * forcing a change in pixa or boxa. However, if pixa is 00340 * changed, it forces a change in pixaa, and if boxa is 00341 * changed, if forces a change in the other three. 00342 * We define four version numbers: 00343 * PIXAA_VERSION_NUMBER 00344 * PIXA_VERSION_NUMBER 00345 * BOXAA_VERSION_NUMBER 00346 * BOXA_VERSION_NUMBER 00347 * 00348 *-------------------------------------------------------------------------*/ 00349 00350 00351 00352 /*-------------------------------------------------------------------------* 00353 * Array of pix * 00354 *-------------------------------------------------------------------------*/ 00355 00356 /* Serialization for primary data structures */ 00357 #define PIXAA_VERSION_NUMBER 2 00358 #define PIXA_VERSION_NUMBER 2 00359 #define BOXA_VERSION_NUMBER 2 00360 #define BOXAA_VERSION_NUMBER 3 00361 00362 00363 struct Pixa 00364 { 00365 l_int32 n; /* number of Pix in ptr array */ 00366 l_int32 nalloc; /* number of Pix ptrs allocated */ 00367 l_uint32 refcount; /* reference count (1 if no clones) */ 00368 struct Pix **pix; /* the array of ptrs to pix */ 00369 struct Boxa *boxa; /* array of boxes */ 00370 }; 00371 typedef struct Pixa PIXA; 00372 00373 00374 struct Pixaa 00375 { 00376 l_int32 n; /* number of Pixa in ptr array */ 00377 l_int32 nalloc; /* number of Pixa ptrs allocated */ 00378 struct Pixa **pixa; /* array of ptrs to pixa */ 00379 struct Boxa *boxa; /* array of boxes */ 00380 }; 00381 typedef struct Pixaa PIXAA; 00382 00383 00384 /*-------------------------------------------------------------------------* 00385 * Basic rectangle and rectangle arrays * 00386 *-------------------------------------------------------------------------*/ 00387 struct Box 00388 { 00389 l_int32 x; 00390 l_int32 y; 00391 l_int32 w; 00392 l_int32 h; 00393 l_uint32 refcount; /* reference count (1 if no clones) */ 00394 00395 }; 00396 typedef struct Box BOX; 00397 00398 struct Boxa 00399 { 00400 l_int32 n; /* number of box in ptr array */ 00401 l_int32 nalloc; /* number of box ptrs allocated */ 00402 l_uint32 refcount; /* reference count (1 if no clones) */ 00403 struct Box **box; /* box ptr array */ 00404 }; 00405 typedef struct Boxa BOXA; 00406 00407 struct Boxaa 00408 { 00409 l_int32 n; /* number of boxa in ptr array */ 00410 l_int32 nalloc; /* number of boxa ptrs allocated */ 00411 struct Boxa **boxa; /* boxa ptr array */ 00412 }; 00413 typedef struct Boxaa BOXAA; 00414 00415 00416 /*-------------------------------------------------------------------------* 00417 * Array of points * 00418 *-------------------------------------------------------------------------*/ 00419 #define PTA_VERSION_NUMBER 1 00420 00421 struct Pta 00422 { 00423 l_int32 n; /* actual number of pts */ 00424 l_int32 nalloc; /* size of allocated arrays */ 00425 l_int32 refcount; /* reference count (1 if no clones) */ 00426 l_float32 *x, *y; /* arrays of floats */ 00427 }; 00428 typedef struct Pta PTA; 00429 00430 00431 /*-------------------------------------------------------------------------* 00432 * Array of Pta * 00433 *-------------------------------------------------------------------------*/ 00434 struct Ptaa 00435 { 00436 l_int32 n; /* number of pta in ptr array */ 00437 l_int32 nalloc; /* number of pta ptrs allocated */ 00438 struct Pta **pta; /* pta ptr array */ 00439 }; 00440 typedef struct Ptaa PTAA; 00441 00442 00443 /*-------------------------------------------------------------------------* 00444 * Pix accumulator container * 00445 *-------------------------------------------------------------------------*/ 00446 struct Pixacc 00447 { 00448 l_int32 w; /* array width */ 00449 l_int32 h; /* array height */ 00450 l_int32 offset; /* used to allow negative */ 00451 /* intermediate results */ 00452 struct Pix *pix; /* the 32 bit accumulator pix */ 00453 }; 00454 typedef struct Pixacc PIXACC; 00455 00456 00457 /*-------------------------------------------------------------------------* 00458 * Pix tiling * 00459 *-------------------------------------------------------------------------*/ 00460 struct PixTiling 00461 { 00462 struct Pix *pix; /* input pix (a clone) */ 00463 l_int32 nx; /* number of tiles horizontally */ 00464 l_int32 ny; /* number of tiles vertically */ 00465 l_int32 w; /* tile width */ 00466 l_int32 h; /* tile height */ 00467 l_int32 xoverlap; /* overlap on left and right */ 00468 l_int32 yoverlap; /* overlap on top and bottom */ 00469 l_int32 strip; /* strip for paint; default is TRUE */ 00470 }; 00471 typedef struct PixTiling PIXTILING; 00472 00473 00474 /*-------------------------------------------------------------------------* 00475 * FPix: pix with float array * 00476 *-------------------------------------------------------------------------*/ 00477 #define FPIX_VERSION_NUMBER 1 00478 00479 struct FPix 00480 { 00481 l_int32 w; /* width in pixels */ 00482 l_int32 h; /* height in pixels */ 00483 l_int32 wpl; /* 32-bit words/line */ 00484 l_int32 refcount; /* reference count (1 if no clones) */ 00485 l_int32 xres; /* image res (ppi) in x direction */ 00486 /* (use 0 if unknown) */ 00487 l_int32 yres; /* image res (ppi) in y direction */ 00488 /* (use 0 if unknown) */ 00489 l_float32 *data; /* the float image data */ 00490 }; 00491 typedef struct FPix FPIX; 00492 00493 00494 struct FPixa 00495 { 00496 l_int32 n; /* number of Pix in ptr array */ 00497 l_int32 nalloc; /* number of Pix ptrs allocated */ 00498 l_uint32 refcount; /* reference count (1 if no clones) */ 00499 struct FPix **fpix; /* the array of ptrs to fpix */ 00500 }; 00501 typedef struct FPixa FPIXA; 00502 00503 00504 /*-------------------------------------------------------------------------* 00505 * DPix: pix with double array * 00506 *-------------------------------------------------------------------------*/ 00507 #define DPIX_VERSION_NUMBER 1 00508 00509 struct DPix 00510 { 00511 l_int32 w; /* width in pixels */ 00512 l_int32 h; /* height in pixels */ 00513 l_int32 wpl; /* 32-bit words/line */ 00514 l_int32 refcount; /* reference count (1 if no clones) */ 00515 l_int32 xres; /* image res (ppi) in x direction */ 00516 /* (use 0 if unknown) */ 00517 l_int32 yres; /* image res (ppi) in y direction */ 00518 /* (use 0 if unknown) */ 00519 l_float64 *data; /* the double image data */ 00520 }; 00521 typedef struct DPix DPIX; 00522 00523 00524 /*-------------------------------------------------------------------------* 00525 * PixComp: compressed pix * 00526 *-------------------------------------------------------------------------*/ 00527 struct PixComp 00528 { 00529 l_int32 w; /* width in pixels */ 00530 l_int32 h; /* height in pixels */ 00531 l_int32 d; /* depth in bits */ 00532 l_int32 xres; /* image res (ppi) in x direction */ 00533 /* (use 0 if unknown) */ 00534 l_int32 yres; /* image res (ppi) in y direction */ 00535 /* (use 0 if unknown) */ 00536 l_int32 comptype; /* compressed format (IFF_TIFF_G4, */ 00537 /* IFF_PNG, IFF_JFIF_JPEG) */ 00538 char *text; /* text string associated with pix */ 00539 l_int32 cmapflag; /* flag (1 for cmap, 0 otherwise) */ 00540 l_uint8 *data; /* the compressed image data */ 00541 size_t size; /* size of the data array */ 00542 }; 00543 typedef struct PixComp PIXC; 00544 00545 00546 /*-------------------------------------------------------------------------* 00547 * PixaComp: array of compressed pix * 00548 *-------------------------------------------------------------------------*/ 00549 #define PIXACOMP_VERSION_NUMBER 1 00550 00551 struct PixaComp 00552 { 00553 l_int32 n; /* number of PixComp in ptr array */ 00554 l_int32 nalloc; /* number of PixComp ptrs allocated */ 00555 struct PixComp **pixc; /* the array of ptrs to PixComp */ 00556 struct Boxa *boxa; /* array of boxes */ 00557 }; 00558 typedef struct PixaComp PIXAC; 00559 00560 00561 /*-------------------------------------------------------------------------* 00562 * Access and storage flags * 00563 *-------------------------------------------------------------------------*/ 00564 /* 00565 * For Pix, Box, Pta and Numa, there are 3 standard methods for handling 00566 * the retrieval or insertion of a struct: 00567 * (1) direct insertion (Don't do this if there is another handle 00568 * somewhere to this same struct!) 00569 * (2) copy (Always safe, sets up a refcount of 1 on the new object. 00570 * Can be undesirable if very large, such as an image or 00571 * an array of images.) 00572 * (3) clone (Makes another handle to the same struct, and bumps the 00573 * refcount up by 1. Safe to do unless you're changing 00574 * data through one of the handles but don't want those 00575 * changes to be seen by the other handle.) 00576 * 00577 * For Pixa and Boxa, which are structs that hold an array of clonable 00578 * structs, there is an additional method: 00579 * (4) copy-clone (Makes a new higher-level struct with a refcount 00580 * of 1, but clones all the structs in the array.) 00581 * 00582 * Unlike the other structs, when retrieving a string from an Sarray, 00583 * you are allowed to get a handle without a copy or clone (i.e., that 00584 * you don't own!). You must not free or insert such a string! 00585 * Specifically, for an Sarray, the copyflag for retrieval is either: 00586 * TRUE (or 1 or L_COPY) 00587 * or 00588 * FALSE (or 0 or L_NOCOPY) 00589 * For insertion, the copyflag is either: 00590 * TRUE (or 1 or L_COPY) 00591 * or 00592 * FALSE (or 0 or L_INSERT) 00593 * Note that L_COPY is always 1, and L_INSERT and L_NOCOPY are always 0. 00594 */ 00595 enum { 00596 L_INSERT = 0, /* stuff it in; no copy, clone or copy-clone */ 00597 L_COPY = 1, /* make/use a copy of the object */ 00598 L_CLONE = 2, /* make/use clone (ref count) of the object */ 00599 L_COPY_CLONE = 3 /* make a new object and fill with with clones */ 00600 /* of each object in the array(s) */ 00601 }; 00602 static const l_int32 L_NOCOPY = 0; /* copyflag value in sarrayGetString() */ 00603 00604 00605 /*--------------------------------------------------------------------------* 00606 * Sort flags * 00607 *--------------------------------------------------------------------------*/ 00608 enum { 00609 L_SORT_INCREASING = 1, /* sort in increasing order */ 00610 L_SORT_DECREASING = 2 /* sort in decreasing order */ 00611 }; 00612 00613 enum { 00614 L_SORT_BY_X = 3, /* sort box or c.c. by horiz location */ 00615 L_SORT_BY_Y = 4, /* sort box or c.c. by vert location */ 00616 L_SORT_BY_WIDTH = 5, /* sort box or c.c. by width */ 00617 L_SORT_BY_HEIGHT = 6, /* sort box or c.c. by height */ 00618 L_SORT_BY_MIN_DIMENSION = 7, /* sort box or c.c. by min dimension */ 00619 L_SORT_BY_MAX_DIMENSION = 8, /* sort box or c.c. by max dimension */ 00620 L_SORT_BY_PERIMETER = 9, /* sort box or c.c. by perimeter */ 00621 L_SORT_BY_AREA = 10, /* sort box or c.c. by area */ 00622 L_SORT_BY_ASPECT_RATIO = 11 /* sort box or c.c. by width/height ratio */ 00623 }; 00624 00625 00626 /*-------------------------------------------------------------------------* 00627 * Blend flags * 00628 *-------------------------------------------------------------------------*/ 00629 enum { 00630 L_BLEND_WITH_INVERSE = 1, /* add some of src inverse to itself */ 00631 L_BLEND_TO_WHITE = 2, /* shift src colors towards white */ 00632 L_BLEND_TO_BLACK = 3, /* shift src colors towards black */ 00633 L_BLEND_GRAY = 4, /* blend src directly with blender */ 00634 L_BLEND_GRAY_WITH_INVERSE = 5 /* add amount of src inverse to itself, */ 00635 /* based on blender pix value */ 00636 }; 00637 00638 enum { 00639 L_PAINT_LIGHT = 1, /* colorize non-black pixels */ 00640 L_PAINT_DARK = 2 /* colorize non-white pixels */ 00641 }; 00642 00643 00644 /*-------------------------------------------------------------------------* 00645 * Graphics pixel setting * 00646 *-------------------------------------------------------------------------*/ 00647 enum { 00648 L_SET_PIXELS = 1, /* set all bits in each pixel to 1 */ 00649 L_CLEAR_PIXELS = 2, /* set all bits in each pixel to 0 */ 00650 L_FLIP_PIXELS = 3 /* flip all bits in each pixel */ 00651 }; 00652 00653 00654 /*-------------------------------------------------------------------------* 00655 * Size filter flags * 00656 *-------------------------------------------------------------------------*/ 00657 enum { 00658 L_SELECT_WIDTH = 1, /* width must satisfy constraint */ 00659 L_SELECT_HEIGHT = 2, /* height must satisfy constraint */ 00660 L_SELECT_IF_EITHER = 3, /* either width or height can satisfy */ 00661 L_SELECT_IF_BOTH = 4 /* both width and height must satisfy */ 00662 }; 00663 00664 enum { 00665 L_SELECT_IF_LT = 1, /* save if value is less than threshold */ 00666 L_SELECT_IF_GT = 2, /* save if value is more than threshold */ 00667 L_SELECT_IF_LTE = 3, /* save if value is <= to the threshold */ 00668 L_SELECT_IF_GTE = 4 /* save if value is >= to the threshold */ 00669 }; 00670 00671 00672 /*-------------------------------------------------------------------------* 00673 * Color component selection flags * 00674 *-------------------------------------------------------------------------*/ 00675 enum { 00676 L_SELECT_RED = 1, /* use red component */ 00677 L_SELECT_GREEN = 2, /* use green component */ 00678 L_SELECT_BLUE = 3, /* use blue component */ 00679 L_SELECT_MIN = 4, /* use min color component */ 00680 L_SELECT_MAX = 5 /* use max color component */ 00681 }; 00682 00683 00684 /*-------------------------------------------------------------------------* 00685 * Rotate and shear flags * 00686 *-------------------------------------------------------------------------*/ 00687 enum { 00688 L_ROTATE_AREA_MAP = 1, /* use area map rotation, if possible */ 00689 L_ROTATE_SHEAR = 2, /* use shear rotation */ 00690 L_ROTATE_SAMPLING = 3 /* use sampling */ 00691 }; 00692 00693 enum { 00694 L_BRING_IN_WHITE = 1, /* bring in white pixels from the outside */ 00695 L_BRING_IN_BLACK = 2 /* bring in black pixels from the outside */ 00696 }; 00697 00698 enum { 00699 L_SHEAR_ABOUT_CORNER = 1, /* shear image about UL corner */ 00700 L_SHEAR_ABOUT_CENTER = 2 /* shear image about center */ 00701 }; 00702 00703 00704 /*-------------------------------------------------------------------------* 00705 * Affine transform order flags * 00706 *-------------------------------------------------------------------------*/ 00707 enum { 00708 L_TR_SC_RO = 1, /* translate, scale, rotate */ 00709 L_SC_RO_TR = 2, /* scale, rotate, translate */ 00710 L_RO_TR_SC = 3, /* rotate, translate, scale */ 00711 L_TR_RO_SC = 4, /* translate, rotate, scale */ 00712 L_RO_SC_TR = 5, /* rotate, scale, translate */ 00713 L_SC_TR_RO = 6 /* scale, translate, rotate */ 00714 }; 00715 00716 00717 /*-------------------------------------------------------------------------* 00718 * Grayscale filling flags * 00719 *-------------------------------------------------------------------------*/ 00720 enum { 00721 L_FILL_WHITE = 1, /* fill white pixels (e.g, in fg map) */ 00722 L_FILL_BLACK = 2 /* fill black pixels (e.g., in bg map) */ 00723 }; 00724 00725 00726 /*-------------------------------------------------------------------------* 00727 * Flags for setting to white or black * 00728 *-------------------------------------------------------------------------*/ 00729 enum { 00730 L_SET_WHITE = 1, /* set pixels to white */ 00731 L_SET_BLACK = 2 /* set pixels to black */ 00732 }; 00733 00734 00735 /*-------------------------------------------------------------------------* 00736 * Dither parameters * 00737 * If within this grayscale distance from black or white, * 00738 * do not propagate excess or deficit to neighboring pixels. * 00739 *-------------------------------------------------------------------------*/ 00740 enum { 00741 DEFAULT_CLIP_LOWER_1 = 10, /* dist to black with no prop; 1 bpp */ 00742 DEFAULT_CLIP_UPPER_1 = 10, /* dist to black with no prop; 1 bpp */ 00743 DEFAULT_CLIP_LOWER_2 = 5, /* dist to black with no prop; 2 bpp */ 00744 DEFAULT_CLIP_UPPER_2 = 5 /* dist to black with no prop; 2 bpp */ 00745 }; 00746 00747 00748 /*-------------------------------------------------------------------------* 00749 * Distance flags * 00750 *-------------------------------------------------------------------------*/ 00751 enum { 00752 L_MANHATTAN_DISTANCE = 1, /* L1 distance (e.g., in color space) */ 00753 L_EUCLIDEAN_DISTANCE = 2 /* L2 distance */ 00754 }; 00755 00756 00757 /*-------------------------------------------------------------------------* 00758 * Statistical measures * 00759 *-------------------------------------------------------------------------*/ 00760 enum { 00761 L_MEAN_ABSVAL = 1, /* average of abs values */ 00762 L_MEDIAN_VAL = 2, /* median value of set */ 00763 L_MODE_VAL = 3, /* mode value of set */ 00764 L_MODE_COUNT = 4, /* mode count of set */ 00765 L_ROOT_MEAN_SQUARE = 5, /* rms of values */ 00766 L_STANDARD_DEVIATION = 6, /* standard deviation from mean */ 00767 L_VARIANCE = 7 /* variance of values */ 00768 }; 00769 00770 00771 /*-------------------------------------------------------------------------* 00772 * Set selection flags * 00773 *-------------------------------------------------------------------------*/ 00774 enum { 00775 L_CHOOSE_CONSECUTIVE = 1, /* select 'n' consecutive */ 00776 L_CHOOSE_SKIP_BY = 2 /* select at intervals of 'n' */ 00777 }; 00778 00779 00780 /*-------------------------------------------------------------------------* 00781 * Text orientation flags * 00782 *-------------------------------------------------------------------------*/ 00783 enum { 00784 L_TEXT_ORIENT_UNKNOWN = 0, /* low confidence on text orientation */ 00785 L_TEXT_ORIENT_UP = 1, /* portrait, text rightside-up */ 00786 L_TEXT_ORIENT_LEFT = 2, /* landscape, text up to left */ 00787 L_TEXT_ORIENT_DOWN = 3, /* portrait, text upside-down */ 00788 L_TEXT_ORIENT_RIGHT = 4 /* landscape, text up to right */ 00789 }; 00790 00791 00792 /*-------------------------------------------------------------------------* 00793 * Edge orientation flags * 00794 *-------------------------------------------------------------------------*/ 00795 enum { 00796 L_HORIZONTAL_EDGES = 0, /* filters for horizontal edges */ 00797 L_VERTICAL_EDGES = 1, /* filters for vertical edges */ 00798 L_ALL_EDGES = 2 /* filters for all edges */ 00799 }; 00800 00801 00802 /*-------------------------------------------------------------------------* 00803 * Line orientation flags * 00804 *-------------------------------------------------------------------------*/ 00805 enum { 00806 L_HORIZONTAL_LINE = 0, /* horizontal line */ 00807 L_POS_SLOPE_LINE = 1, /* 45 degree line with positive slope */ 00808 L_VERTICAL_LINE = 2, /* vertical line */ 00809 L_NEG_SLOPE_LINE = 3, /* 45 degree line with negative slope */ 00810 L_OBLIQUE_LINE = 4 /* neither horizontal nor vertical */ 00811 }; 00812 00813 00814 /*-------------------------------------------------------------------------* 00815 * Scan direction flags * 00816 *-------------------------------------------------------------------------*/ 00817 enum { 00818 L_FROM_LEFT = 0, /* scan from left */ 00819 L_FROM_RIGHT = 1, /* scan from right */ 00820 L_FROM_TOP = 2, /* scan from top */ 00821 L_FROM_BOTTOM = 3 /* scan from bottom */ 00822 }; 00823 00824 00825 /*-------------------------------------------------------------------------* 00826 * Horizontal warp * 00827 *-------------------------------------------------------------------------*/ 00828 enum { 00829 L_WARP_TO_LEFT = 1, /* increasing stretch or contraction to left */ 00830 L_WARP_TO_RIGHT = 2 /* increasing stretch or contraction to right */ 00831 }; 00832 00833 enum { 00834 L_LINEAR_WARP = 1, /* stretch or contraction grows linearly */ 00835 L_QUADRATIC_WARP = 2 /* stretch or contraction grows quadratically */ 00836 }; 00837 00838 00839 /*-------------------------------------------------------------------------* 00840 * Pixel selection for resampling * 00841 *-------------------------------------------------------------------------*/ 00842 enum { 00843 L_INTERPOLATED = 1, /* linear interpolation from src pixels */ 00844 L_SAMPLED = 2 /* nearest src pixel sampling only */ 00845 }; 00846 00847 00848 /*-------------------------------------------------------------------------* 00849 * Thinning flags * 00850 *-------------------------------------------------------------------------*/ 00851 enum { 00852 L_THIN_FG = 1, /* thin foreground of 1 bpp image */ 00853 L_THIN_BG = 2 /* thin background of 1 bpp image */ 00854 }; 00855 00856 00857 /*-------------------------------------------------------------------------* 00858 * Runlength flags * 00859 *-------------------------------------------------------------------------*/ 00860 enum { 00861 L_HORIZONTAL_RUNS = 0, /* determine runlengths of horizontal runs */ 00862 L_VERTICAL_RUNS = 1 /* determine runlengths of vertical runs */ 00863 }; 00864 00865 00866 /*-------------------------------------------------------------------------* 00867 * Edge filter flags * 00868 *-------------------------------------------------------------------------*/ 00869 enum { 00870 L_SOBEL_EDGE = 1, /* Sobel edge filter */ 00871 L_TWO_SIDED_EDGE = 2 /* Two-sided edge filter */ 00872 }; 00873 00874 00875 /*-------------------------------------------------------------------------* 00876 * Handling negative values in conversion to unsigned int * 00877 *-------------------------------------------------------------------------*/ 00878 enum { 00879 L_CLIP_TO_ZERO = 1, /* Clip negative values to 0 */ 00880 L_TAKE_ABSVAL = 2 /* Convert to positive using L_ABS() */ 00881 }; 00882 00883 00884 /*-------------------------------------------------------------------------* 00885 * Subpixel color component ordering in LCD display * 00886 *-------------------------------------------------------------------------*/ 00887 enum { 00888 L_SUBPIXEL_ORDER_RGB = 1, /* sensor order left-to-right RGB */ 00889 L_SUBPIXEL_ORDER_BGR = 2, /* sensor order left-to-right BGR */ 00890 L_SUBPIXEL_ORDER_VRGB = 3, /* sensor order top-to-bottom RGB */ 00891 L_SUBPIXEL_ORDER_VBGR = 4 /* sensor order top-to-bottom BGR */ 00892 }; 00893 00894 00895 /*-------------------------------------------------------------------------* 00896 * Relative to zero flags * 00897 *-------------------------------------------------------------------------*/ 00898 enum { 00899 L_LESS_THAN_ZERO = 1, /* Choose values less than zero */ 00900 L_EQUAL_TO_ZERO = 2, /* Choose values equal to zero */ 00901 L_GREATER_THAN_ZERO = 3 /* Choose values greater than zero */ 00902 }; 00903 00904 00905 /*-------------------------------------------------------------------------* 00906 * HSV histogram flags * 00907 *-------------------------------------------------------------------------*/ 00908 enum { 00909 L_HS_HISTO = 1, /* Use hue-saturation histogram */ 00910 L_HV_HISTO = 2, /* Use hue-value histogram */ 00911 L_SV_HISTO = 3 /* Use saturation-value histogram */ 00912 }; 00913 00914 00915 /*-------------------------------------------------------------------------* 00916 * Region flags (inclusion, exclusion) * 00917 *-------------------------------------------------------------------------*/ 00918 enum { 00919 L_INCLUDE_REGION = 1, /* Use hue-saturation histogram */ 00920 L_EXCLUDE_REGION = 2 /* Use hue-value histogram */ 00921 }; 00922 00923 00924 /*-------------------------------------------------------------------------* 00925 * Flags for adding text to a pix * 00926 *-------------------------------------------------------------------------*/ 00927 enum { 00928 L_ADD_ABOVE = 1, /* Add text above the image */ 00929 L_ADD_AT_TOP = 2, /* Add text over the top of the image */ 00930 L_ADD_AT_BOTTOM = 3, /* Add text over the bottom of the image */ 00931 L_ADD_BELOW = 4 /* Add text below the image */ 00932 }; 00933 00934 00935 /*-------------------------------------------------------------------------* 00936 * Flags for selecting display program * 00937 *-------------------------------------------------------------------------*/ 00938 enum { 00939 L_DISPLAY_WITH_XV = 1, /* Use xv with pixDisplay() */ 00940 L_DISPLAY_WITH_XLI = 2, /* Use xli with pixDisplay() */ 00941 L_DISPLAY_WITH_XZGV = 3, /* Use xzgv with pixDisplay() */ 00942 L_DISPLAY_WITH_IV = 4 /* Use irfvanview with pixDisplay() */ 00943 }; 00944 00945 #endif /* LEPTONICA_PIX_H */