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