Leptonica  1.77.0
Image processing and image analysis suite
pix.h
Go to the documentation of this file.
1 /*====================================================================*
2  - Copyright (C) 2001 Leptonica. All rights reserved.
3  -
4  - Redistribution and use in source and binary forms, with or without
5  - modification, are permitted provided that the following conditions
6  - are met:
7  - 1. Redistributions of source code must retain the above copyright
8  - notice, this list of conditions and the following disclaimer.
9  - 2. Redistributions in binary form must reproduce the above
10  - copyright notice, this list of conditions and the following
11  - disclaimer in the documentation and/or other materials
12  - provided with the distribution.
13  -
14  - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17  - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
18  - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *====================================================================*/
26 
27 #ifndef LEPTONICA_PIX_H
28 #define LEPTONICA_PIX_H
29 
127 /*-------------------------------------------------------------------------*
128  * Basic Pix *
129  *-------------------------------------------------------------------------*/
130  /* The 'special' field is by default 0, but it can hold integers
131  * that direct non-default actions, e.g., in png and jpeg I/O. */
132 
134 struct Pix
135 {
136  l_uint32 w;
137  l_uint32 h;
138  l_uint32 d;
139  l_uint32 spp;
140  l_uint32 wpl;
141  l_uint32 refcount;
142  l_int32 xres;
144  l_int32 yres;
146  l_int32 informat;
147  l_int32 special;
148  char *text;
150  l_uint32 *data;
151 };
152 typedef struct Pix PIX;
153 
156 {
157  void *array;
158  l_int32 depth;
159  l_int32 nalloc;
160  l_int32 n;
161 };
162 typedef struct PixColormap PIXCMAP;
163 
164 
169 struct RGBA_Quad
170 {
171  l_uint8 blue;
172  l_uint8 green;
173  l_uint8 red;
174  l_uint8 alpha;
175 };
176 typedef struct RGBA_Quad RGBA_QUAD;
177 
178 
179 
180 /*-------------------------------------------------------------------------*
181  * Colors for 32 bpp *
182  *-------------------------------------------------------------------------*/
183 /* <pre>
184  * Notes:
185  * (1) These are the byte indices for colors in 32 bpp images.
186  * They are used through the GET/SET_DATA_BYTE accessors.
187  * The 4th byte, typically known as the "alpha channel" and used
188  * for blending, is used to a small extent in leptonica.
189  * (2) Do not change these values! If you redefine them, functions
190  * that have the shifts hardcoded for efficiency and conciseness
191  * (instead of using the constants below) will break. These
192  * functions are labelled with "***" next to their names at
193  * the top of the files in which they are defined.
194  * (3) The shifts to extract the red, green, blue and alpha components
195  * from a 32 bit pixel are defined here.
196  * </pre>
197  */
198 
200 enum {
201  COLOR_RED = 0,
205 };
206 
207 static const l_int32 L_RED_SHIFT =
208  8 * (sizeof(l_uint32) - 1 - COLOR_RED); /* 24 */
209 static const l_int32 L_GREEN_SHIFT =
210  8 * (sizeof(l_uint32) - 1 - COLOR_GREEN); /* 16 */
211 static const l_int32 L_BLUE_SHIFT =
212  8 * (sizeof(l_uint32) - 1 - COLOR_BLUE); /* 8 */
213 static const l_int32 L_ALPHA_SHIFT =
214  8 * (sizeof(l_uint32) - 1 - L_ALPHA_CHANNEL); /* 0 */
215 
216 
217 /*-------------------------------------------------------------------------*
218  * Colors for drawing boxes *
219  *-------------------------------------------------------------------------*/
221 enum {
228 };
229 
230 
231 /*-------------------------------------------------------------------------*
232  * Perceptual color weights *
233  *-------------------------------------------------------------------------*/
234 /* <pre>
235  * Notes:
236  * (1) These perceptual weighting factors are ad-hoc, but they do
237  * add up to 1. Unlike, for example, the weighting factors for
238  * converting RGB to luminance, or more specifically to Y in the
239  * YUV colorspace. Those numbers come from the
240  * International Telecommunications Union, via ITU-R.
241  * </pre>
242  */
243 static const l_float32 L_RED_WEIGHT = 0.3f;
244 static const l_float32 L_GREEN_WEIGHT = 0.5f;
245 static const l_float32 L_BLUE_WEIGHT = 0.2f;
248 /*-------------------------------------------------------------------------*
249  * Flags for colormap conversion *
250  *-------------------------------------------------------------------------*/
252 enum {
258 };
259 
260 
261 /*------------------------------------------------------------------------*
262  *!
263  * <pre>
264  * The following operation bit flags have been modified from
265  * Sun's pixrect.h.
266  *
267  * The 'op' in 'rasterop' is represented by an integer
268  * composed with Boolean functions using the set of five integers
269  * given below. The integers, and the op codes resulting from
270  * boolean expressions on them, need only be in the range from 0 to 15.
271  * The function is applied on a per-pixel basis.
272  *
273  * Examples: the op code representing ORing the src and dest
274  * is computed using the bit OR, as PIX_SRC | PIX_DST; the op
275  * code representing XORing src and dest is found from
276  * PIX_SRC ^ PIX_DST; the op code representing ANDing src and dest
277  * is found from PIX_SRC & PIX_DST. Note that
278  * PIX_NOT(PIX_CLR) = PIX_SET, and v.v., as they must be.
279  *
280  * We use the following set of definitions:
281  *
282  * #define PIX_SRC 0xc
283  * #define PIX_DST 0xa
284  * #define PIX_NOT(op) (op) ^ 0xf
285  * #define PIX_CLR 0x0
286  * #define PIX_SET 0xf
287  *
288  * These definitions differ from Sun's, in that Sun left-shifted
289  * each value by 1 pixel, and used the least significant bit as a
290  * flag for the "pseudo-operation" of clipping. We don't need
291  * this bit, because it is both efficient and safe ALWAYS to clip
292  * the rectangles to the src and dest images, which is what we do.
293  * See the notes in rop.h on the general choice of these bit flags.
294  *
295  * [If for some reason you need compatibility with Sun's xview package,
296  * you can adopt the original Sun definitions to avoid redefinition conflicts:
297  *
298  * #define PIX_SRC (0xc << 1)
299  * #define PIX_DST (0xa << 1)
300  * #define PIX_NOT(op) ((op) ^ 0x1e)
301  * #define PIX_CLR (0x0 << 1)
302  * #define PIX_SET (0xf << 1)
303  * ]
304  *
305  * We have, for reference, the following 16 unique op flags:
306  *
307  * PIX_CLR 0000 0x0
308  * PIX_SET 1111 0xf
309  * PIX_SRC 1100 0xc
310  * PIX_DST 1010 0xa
311  * PIX_NOT(PIX_SRC) 0011 0x3
312  * PIX_NOT(PIX_DST) 0101 0x5
313  * PIX_SRC | PIX_DST 1110 0xe
314  * PIX_SRC & PIX_DST 1000 0x8
315  * PIX_SRC ^ PIX_DST 0110 0x6
316  * PIX_NOT(PIX_SRC) | PIX_DST 1011 0xb
317  * PIX_NOT(PIX_SRC) & PIX_DST 0010 0x2
318  * PIX_SRC | PIX_NOT(PIX_DST) 1101 0xd
319  * PIX_SRC & PIX_NOT(PIX_DST) 0100 0x4
320  * PIX_NOT(PIX_SRC | PIX_DST) 0001 0x1
321  * PIX_NOT(PIX_SRC & PIX_DST) 0111 0x7
322  * PIX_NOT(PIX_SRC ^ PIX_DST) 1001 0x9
323  *
324  * </pre>
325  *-------------------------------------------------------------------------*/
326 
327 #define PIX_SRC (0xc)
328 #define PIX_DST (0xa)
329 #define PIX_NOT(op) ((op) ^ 0x0f)
330 #define PIX_CLR (0x0)
331 #define PIX_SET (0xf)
333 #define PIX_PAINT (PIX_SRC | PIX_DST)
334 #define PIX_MASK (PIX_SRC & PIX_DST)
335 #define PIX_SUBTRACT (PIX_DST & PIX_NOT(PIX_SRC))
337 #define PIX_XOR (PIX_SRC ^ PIX_DST)
340 /*-------------------------------------------------------------------------*
341  * <pre>
342  * Important Notes:
343  *
344  * (1) The image data is stored in a single contiguous
345  * array of l_uint32, into which the pixels are packed.
346  * By "packed" we mean that there are no unused bits
347  * between pixels, except for end-of-line padding to
348  * satisfy item (2) below.
349  *
350  * (2) Every image raster line begins on a 32-bit word
351  * boundary within this array.
352  *
353  * (3) Pix image data is stored in 32-bit units, with the
354  * pixels ordered from left to right in the image being
355  * stored in order from the MSB to LSB within the word,
356  * for both big-endian and little-endian machines.
357  * This is the natural ordering for big-endian machines,
358  * as successive bytes are stored and fetched progressively
359  * to the right. However, for little-endians, when storing
360  * we re-order the bytes from this byte stream order, and
361  * reshuffle again for byte access on 32-bit entities.
362  * So if the bytes come in sequence from left to right, we
363  * store them on little-endians in byte order:
364  * 3 2 1 0 7 6 5 4 ...
365  * This MSB to LSB ordering allows left and right shift
366  * operations on 32 bit words to move the pixels properly.
367  *
368  * (4) We use 32 bit pixels for both RGB and RGBA color images.
369  * The A (alpha) byte is ignored in most leptonica functions
370  * operating on color images. Within each 4 byte pixel, the
371  * color samples are ordered from MSB to LSB, as follows:
372  *
373  * | MSB | 2nd MSB | 3rd MSB | LSB |
374  * red green blue alpha
375  * 0 1 2 3 (big-endian)
376  * 3 2 1 0 (little-endian)
377  *
378  * Because we use MSB to LSB ordering within the 32-bit word,
379  * the individual 8-bit samples can be accessed with
380  * GET_DATA_BYTE and SET_DATA_BYTE macros, using the
381  * (implicitly big-ending) ordering
382  * red: byte 0 (MSB)
383  * green: byte 1 (2nd MSB)
384  * blue: byte 2 (3rd MSB)
385  * alpha: byte 3 (LSB)
386  *
387  * The specific color assignment is made in this file,
388  * through the definitions of COLOR_RED, etc. Then the R, G
389  * B and A sample values can be retrieved using
390  * redval = GET_DATA_BYTE(&pixel, COLOR_RED);
391  * greenval = GET_DATA_BYTE(&pixel, COLOR_GREEN);
392  * blueval = GET_DATA_BYTE(&pixel, COLOR_BLUE);
393  * alphaval = GET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL);
394  * and they can be set with
395  * SET_DATA_BYTE(&pixel, COLOR_RED, redval);
396  * SET_DATA_BYTE(&pixel, COLOR_GREEN, greenval);
397  * SET_DATA_BYTE(&pixel, COLOR_BLUE, blueval);
398  * SET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL, alphaval);
399  *
400  * More efficiently, these components can be extracted directly
401  * by shifting and masking, explicitly using the values in
402  * L_RED_SHIFT, etc.:
403  * (pixel32 >> L_RED_SHIFT) & 0xff; (red)
404  * (pixel32 >> L_GREEN_SHIFT) & 0xff; (green)
405  * (pixel32 >> L_BLUE_SHIFT) & 0xff; (blue)
406  * (pixel32 >> L_ALPHA_SHIFT) & 0xff; (alpha)
407  * The functions extractRGBValues() and extractRGBAValues() are
408  * provided to do this. Likewise, the pixels can be set
409  * directly by shifting, using composeRGBPixel() and
410  * composeRGBAPixel().
411  *
412  * All these operations work properly on both big- and little-endians.
413  *
414  * (5) A reference count is held within each pix, giving the
415  * number of ptrs to the pix. When a pixClone() call
416  * is made, the ref count is increased by 1, and
417  * when a pixDestroy() call is made, the reference count
418  * of the pix is decremented. The pix is only destroyed
419  * when the reference count goes to zero.
420  *
421  * (6) The version numbers (below) are used in the serialization
422  * of these data structures. They are placed in the files,
423  * and rarely (if ever) change. Provision is currently made for
424  * backward compatibility in reading from boxaa version 2.
425  *
426  * (7) The serialization dependencies are as follows:
427  * pixaa : pixa : boxa
428  * boxaa : boxa
429  * So, for example, pixaa and boxaa can be changed without
430  * forcing a change in pixa or boxa. However, if pixa is
431  * changed, it forces a change in pixaa, and if boxa is
432  * changed, if forces a change in the other three.
433  * We define four version numbers:
434  * PIXAA_VERSION_NUMBER
435  * PIXA_VERSION_NUMBER
436  * BOXAA_VERSION_NUMBER
437  * BOXA_VERSION_NUMBER
438  * </pre>
439  *-------------------------------------------------------------------------*/
440 
441 
442 
443 /*-------------------------------------------------------------------------*
444  * Array of pix *
445  *-------------------------------------------------------------------------*/
446 
447  /* Serialization for primary data structures */
448 #define PIXAA_VERSION_NUMBER 2
449 #define PIXA_VERSION_NUMBER 2
450 #define BOXA_VERSION_NUMBER 2
451 #define BOXAA_VERSION_NUMBER 3
454 struct Pixa
455 {
456  l_int32 n;
457  l_int32 nalloc;
458  l_uint32 refcount;
459  struct Pix **pix;
460  struct Boxa *boxa;
461 };
462 typedef struct Pixa PIXA;
463 
465 struct Pixaa
466 {
467  l_int32 n;
468  l_int32 nalloc;
469  struct Pixa **pixa;
470  struct Boxa *boxa;
471 };
472 typedef struct Pixaa PIXAA;
473 
474 
475 /*-------------------------------------------------------------------------*
476  * Basic rectangle and rectangle arrays *
477  *-------------------------------------------------------------------------*/
478 
480 struct Box
481 {
482  l_int32 x;
483  l_int32 y;
484  l_int32 w;
485  l_int32 h;
486  l_uint32 refcount;
488 };
489 typedef struct Box BOX;
490 
492 struct Boxa
493 {
494  l_int32 n;
495  l_int32 nalloc;
496  l_uint32 refcount;
497  struct Box **box;
498 };
499 typedef struct Boxa BOXA;
500 
502 struct Boxaa
503 {
504  l_int32 n;
505  l_int32 nalloc;
506  struct Boxa **boxa;
507 };
508 typedef struct Boxaa BOXAA;
509 
510 
511 /*-------------------------------------------------------------------------*
512  * Array of points *
513  *-------------------------------------------------------------------------*/
514 #define PTA_VERSION_NUMBER 1
517 struct Pta
518 {
519  l_int32 n;
520  l_int32 nalloc;
521  l_uint32 refcount;
522  l_float32 *x, *y;
523 };
524 typedef struct Pta PTA;
525 
526 
527 /*-------------------------------------------------------------------------*
528  * Array of Pta *
529  *-------------------------------------------------------------------------*/
530 
532 struct Ptaa
533 {
534  l_int32 n;
535  l_int32 nalloc;
536  struct Pta **pta;
537 };
538 typedef struct Ptaa PTAA;
539 
540 
541 /*-------------------------------------------------------------------------*
542  * Pix accumulator container *
543  *-------------------------------------------------------------------------*/
544 
546 struct Pixacc
547 {
548  l_int32 w;
549  l_int32 h;
550  l_int32 offset;
552  struct Pix *pix;
553 };
554 typedef struct Pixacc PIXACC;
555 
556 
557 /*-------------------------------------------------------------------------*
558  * Pix tiling *
559  *-------------------------------------------------------------------------*/
560 
562 struct PixTiling
563 {
564  struct Pix *pix;
565  l_int32 nx;
566  l_int32 ny;
567  l_int32 w;
568  l_int32 h;
569  l_int32 xoverlap;
570  l_int32 yoverlap;
571  l_int32 strip;
572 };
573 typedef struct PixTiling PIXTILING;
574 
575 
576 /*-------------------------------------------------------------------------*
577  * FPix: pix with float array *
578  *-------------------------------------------------------------------------*/
579 #define FPIX_VERSION_NUMBER 2
582 struct FPix
583 {
584  l_int32 w;
585  l_int32 h;
586  l_int32 wpl;
587  l_uint32 refcount;
588  l_int32 xres;
590  l_int32 yres;
592  l_float32 *data;
593 };
594 typedef struct FPix FPIX;
595 
597 struct FPixa
598 {
599  l_int32 n;
600  l_int32 nalloc;
601  l_uint32 refcount;
602  struct FPix **fpix;
603 };
604 typedef struct FPixa FPIXA;
605 
606 
607 /*-------------------------------------------------------------------------*
608  * DPix: pix with double array *
609  *-------------------------------------------------------------------------*/
610 #define DPIX_VERSION_NUMBER 2
613 struct DPix
614 {
615  l_int32 w;
616  l_int32 h;
617  l_int32 wpl;
618  l_uint32 refcount;
619  l_int32 xres;
621  l_int32 yres;
623  l_float64 *data;
624 };
625 typedef struct DPix DPIX;
626 
627 
628 /*-------------------------------------------------------------------------*
629  * PixComp: compressed pix *
630  *-------------------------------------------------------------------------*/
631 
633 struct PixComp
634 {
635  l_int32 w;
636  l_int32 h;
637  l_int32 d;
638  l_int32 xres;
640  l_int32 yres;
642  l_int32 comptype;
644  char *text;
645  l_int32 cmapflag;
646  l_uint8 *data;
647  size_t size;
648 };
649 typedef struct PixComp PIXC;
650 
651 
652 /*-------------------------------------------------------------------------*
653  * PixaComp: array of compressed pix *
654  *-------------------------------------------------------------------------*/
655 #define PIXACOMP_VERSION_NUMBER 2
658 struct PixaComp
659 {
660  l_int32 n;
661  l_int32 nalloc;
662  l_int32 offset;
663  struct PixComp **pixc;
664  struct Boxa *boxa;
665 };
666 typedef struct PixaComp PIXAC;
667 
668 
669 /*-------------------------------------------------------------------------*
670  * Access and storage flags *
671  *-------------------------------------------------------------------------*/
672 /*
673  * <pre>
674  * For Pix, Box, Pta and Numa, there are 3 standard methods for handling
675  * the retrieval or insertion of a struct:
676  * (1) direct insertion (Don't do this if there is another handle
677  * somewhere to this same struct!)
678  * (2) copy (Always safe, sets up a refcount of 1 on the new object.
679  * Can be undesirable if very large, such as an image or
680  * an array of images.)
681  * (3) clone (Makes another handle to the same struct, and bumps the
682  * refcount up by 1. OK to use except in two situations:
683  * (a) You change data through one of the handles but don't
684  * want those changes to be seen by the other handle.
685  * (b) The application is multi-threaded. Because the clone
686  * operation is not atomic (e.g., locked with a mutex),
687  * it is possible to end up with an incorrect ref count,
688  * causing either a memory leak or a crash.
689  *
690  * For Pixa and Boxa, which are structs that hold an array of clonable
691  * structs, there is an additional method:
692  * (4) copy-clone (Makes a new higher-level struct with a refcount
693  * of 1, but clones all the structs in the array.)
694  *
695  * Unlike the other structs, when retrieving a string from an Sarray,
696  * you are allowed to get a handle without a copy or clone (i.e., the
697  * string is not owned by the handle). You must not either free the string
698  * or insert it in some other struct that would own it. Specifically,
699  * for an Sarray, the copyflag for retrieval is either:
700  * L_COPY or L_NOCOPY
701  * and for insertion, the copyflag is either:
702  * L_COPY or one of {L_INSERT , L_NOCOPY} (the latter are equivalent
703  * for insertion))
704  * Typical patterns are:
705  * (1) Reference a string in an Sarray with L_NOCOPY and insert a copy
706  * of it in another Sarray with L_COPY.
707  * (2) Copy a string from an Sarray with L_COPY and insert it in
708  * another Sarray with L_INSERT (or L_NOCOPY).
709  * In both cases, a copy is made and both Sarrays own their instance
710  * of that string.
711  * </pre>
712  */
713 
715 enum {
716  L_NOCOPY = 0,
718  L_COPY = 1,
719  L_CLONE = 2,
722 };
723 
724 
725 /*----------------------------------------------------------------------------*
726  * Sort flags *
727  *----------------------------------------------------------------------------*/
728 
730 enum {
733 };
734 
736 enum {
739 };
740 
742 enum {
754 };
755 
756 
757 /*---------------------------------------------------------------------------*
758  * Blend flags *
759  *---------------------------------------------------------------------------*/
760 
762 enum {
769 };
770 
771 enum {
774 };
775 
776 
777 /*-------------------------------------------------------------------------*
778  * Graphics pixel setting *
779  *-------------------------------------------------------------------------*/
780 
782 enum {
786 };
787 
788 
789 /*-------------------------------------------------------------------------*
790  * Size and location filter flags *
791  *-------------------------------------------------------------------------*/
792 
794 enum {
799 };
800 
802 enum {
808 };
809 
811 enum {
820 };
821 
823 enum {
827 };
828 
829 
830 /*-------------------------------------------------------------------------*
831  * Color component selection flags *
832  *-------------------------------------------------------------------------*/
833 
835 enum {
844 };
845 
846 
847 /*-------------------------------------------------------------------------*
848  * 16-bit conversion flags *
849  *-------------------------------------------------------------------------*/
850 
852 enum {
853  L_LS_BYTE = 1,
854  L_MS_BYTE = 2,
860 };
861 
862 
863 /*-------------------------------------------------------------------------*
864  * Rotate and shear flags *
865  *-------------------------------------------------------------------------*/
866 
868 enum {
872 };
873 
875 enum {
878 };
879 
881 enum {
884 };
885 
886 
887 /*-------------------------------------------------------------------------*
888  * Affine transform order flags *
889  *-------------------------------------------------------------------------*/
890 
892 enum {
899 };
900 
901 
902 /*-------------------------------------------------------------------------*
903  * Grayscale filling flags *
904  *-------------------------------------------------------------------------*/
905 
907 enum {
910 };
911 
912 
913 /*-------------------------------------------------------------------------*
914  * Flags for setting to white or black *
915  *-------------------------------------------------------------------------*/
916 
918 enum {
921 };
922 
923 
924 /*-------------------------------------------------------------------------*
925  * Flags for getting white or black value *
926  *-------------------------------------------------------------------------*/
927 
929 enum {
932 };
933 
934 
935 /*-------------------------------------------------------------------------*
936  * Flags for 8 bit and 16 bit pixel sums *
937  *-------------------------------------------------------------------------*/
938 
940 enum {
943 };
944 
945 
946 /*-------------------------------------------------------------------------*
947  * Dither parameters *
948  * If within this grayscale distance from black or white, *
949  * do not propagate excess or deficit to neighboring pixels. *
950  *-------------------------------------------------------------------------*/
951 
953 enum {
958 };
959 
960 
961 /*-------------------------------------------------------------------------*
962  * Distance flags *
963  *-------------------------------------------------------------------------*/
964 
966 enum {
969 };
970 
971 
972 /*-------------------------------------------------------------------------*
973  * Value flags *
974  *-------------------------------------------------------------------------*/
975 
977 enum {
982  L_ZERO = 5,
983  L_ALL = 6
984 };
985 
986 
987 /*-------------------------------------------------------------------------*
988  * Statistical measures *
989  *-------------------------------------------------------------------------*/
990 
992 enum {
1000 };
1001 
1002 
1003 /*-------------------------------------------------------------------------*
1004  * Set selection flags *
1005  *-------------------------------------------------------------------------*/
1006 
1008 enum {
1011 };
1012 
1013 
1014 /*-------------------------------------------------------------------------*
1015  * Text orientation flags *
1016  *-------------------------------------------------------------------------*/
1017 
1019 enum {
1025 };
1026 
1027 
1028 /*-------------------------------------------------------------------------*
1029  * Edge orientation flags *
1030  *-------------------------------------------------------------------------*/
1031 
1033 enum {
1037 };
1038 
1039 
1040 /*-------------------------------------------------------------------------*
1041  * Line orientation flags *
1042  *-------------------------------------------------------------------------*/
1043 
1045 enum {
1051 };
1052 
1053 
1054 /*-------------------------------------------------------------------------*
1055  * Image orientation flags *
1056  *-------------------------------------------------------------------------*/
1057 
1059 enum {
1062 };
1063 
1064 
1065 /*-------------------------------------------------------------------------*
1066  * Scan direction flags *
1067  *-------------------------------------------------------------------------*/
1068 
1070 enum {
1080 };
1081 
1082 
1083 /*-------------------------------------------------------------------------*
1084  * Box size adjustment and location flags *
1085  *-------------------------------------------------------------------------*/
1086 
1088 enum {
1100  L_SET_TOP = 11,
1101  L_SET_BOT = 12,
1102  L_GET_LEFT = 13,
1104  L_GET_TOP = 15,
1106 };
1107 
1108 
1109 /*-------------------------------------------------------------------------*
1110  * Flags for modifying box boundaries using a second box *
1111  *-------------------------------------------------------------------------*/
1112 
1114 enum {
1121 };
1122 
1123 /*-------------------------------------------------------------------------*
1124  * Handling overlapping bounding boxes in boxa *
1125  *-------------------------------------------------------------------------*/
1126 
1128 enum {
1131 };
1132 
1133 /*-------------------------------------------------------------------------*
1134  * Flags for replacing invalid boxes *
1135  *-------------------------------------------------------------------------*/
1136 
1138 enum {
1141 };
1142 
1143 /*-------------------------------------------------------------------------*
1144  * Horizontal warp *
1145  *-------------------------------------------------------------------------*/
1146 
1148 enum {
1151 };
1152 
1154 enum {
1157 };
1158 
1159 
1160 /*-------------------------------------------------------------------------*
1161  * Pixel selection for resampling *
1162  *-------------------------------------------------------------------------*/
1163 
1165 enum {
1168 };
1169 
1170 
1171 /*-------------------------------------------------------------------------*
1172  * Thinning flags *
1173  *-------------------------------------------------------------------------*/
1174 
1176 enum {
1179 };
1180 
1181 
1182 /*-------------------------------------------------------------------------*
1183  * Runlength flags *
1184  *-------------------------------------------------------------------------*/
1185 
1187 enum {
1190 };
1191 
1192 
1193 /*-------------------------------------------------------------------------*
1194  * Edge filter flags *
1195  *-------------------------------------------------------------------------*/
1196 
1198 enum {
1201 };
1202 
1203 
1204 /*-------------------------------------------------------------------------*
1205  * Subpixel color component ordering in LCD display *
1206  *-------------------------------------------------------------------------*/
1207 
1209 enum {
1214 };
1215 
1216 
1217 /*-------------------------------------------------------------------------*
1218  * HSV histogram flags *
1219  *-------------------------------------------------------------------------*/
1220 
1222 enum {
1226 };
1227 
1228 
1229 /*-------------------------------------------------------------------------*
1230  * Region flags (inclusion, exclusion) *
1231  *-------------------------------------------------------------------------*/
1232 
1234 enum {
1237 };
1238 
1239 
1240 /*-------------------------------------------------------------------------*
1241  * Flags for adding text to a pix *
1242  *-------------------------------------------------------------------------*/
1243 
1245 enum {
1254 };
1255 
1256 
1257 /*-------------------------------------------------------------------------*
1258  * Flags for plotting on a pix *
1259  *-------------------------------------------------------------------------*/
1260 
1262 enum {
1269 };
1270 
1271 
1272 /*-------------------------------------------------------------------------*
1273  * Flags for selecting display program *
1274  *-------------------------------------------------------------------------*/
1275 
1277 enum {
1283 };
1284 
1285 /*-------------------------------------------------------------------------*
1286  * Flag(s) used in the 'special' pix field for non-default operations *
1287  * - 0 is default for chroma sampling in jpeg *
1288  * - 10-19 are used for zlib compression in png write *
1289  * - 4 and 8 are used for specifying connectivity in labelling *
1290  *-------------------------------------------------------------------------*/
1291 
1293 enum {
1295 };
1296 
1297 
1298 /*-------------------------------------------------------------------------*
1299  * Handling negative values in conversion to unsigned int *
1300  *-------------------------------------------------------------------------*/
1301 
1303 enum {
1306 };
1307 
1308 
1309 /*-------------------------------------------------------------------------*
1310  * Relative to zero flags *
1311  *-------------------------------------------------------------------------*/
1312 
1314 enum {
1318 };
1319 
1320 
1321 /*-------------------------------------------------------------------------*
1322  * Flags for adding or removing traling slash from string *
1323  *-------------------------------------------------------------------------*/
1324 
1326 enum {
1329 };
1330 
1331 
1332 /*-------------------------------------------------------------------------*
1333  * Pix allocator and deallocator function types *
1334  *-------------------------------------------------------------------------*/
1336 typedef void *(*alloc_fn)(size_t);
1337 
1339 typedef void (*dealloc_fn)(void *);
1340 
1341 
1342 #endif /* LEPTONICA_PIX_H */
l_uint8 alpha
Definition: pix.h:174
l_int32 xres
Definition: pix.h:142
l_uint32 * data
Definition: pix.h:150
l_int32 n
Definition: pix.h:494
l_uint32 refcount
Definition: pix.h:618
l_uint32 refcount
Definition: pix.h:496
Definition: pix.h:717
Definition: pix.h:854
struct FPix ** fpix
Definition: pix.h:602
l_uint32 w
Definition: pix.h:136
l_int32 w
Definition: pix.h:548
l_int32 special
Definition: pix.h:147
struct Boxa * boxa
Definition: pix.h:460
l_int32 n
Definition: pix.h:160
l_int32 yres
Definition: pix.h:621
l_int32 informat
Definition: pix.h:146
l_uint32 refcount
Definition: pix.h:587
l_int32 h
Definition: pix.h:549
static const l_float32 L_RED_WEIGHT
Definition: pix.h:243
l_uint32 refcount
Definition: pix.h:486
l_uint32 refcount
Definition: pix.h:141
Definition: pix.h:716
l_int32 yres
Definition: pix.h:144
l_int32 w
Definition: pix.h:567
struct PixColormap * colormap
Definition: pix.h:149
Definition: pix.h:983
l_int32 y
Definition: pix.h:483
l_int32 comptype
Definition: pix.h:642
struct Boxa ** boxa
Definition: pix.h:506
l_uint8 red
Definition: pix.h:173
void(* dealloc_fn)(void *)
Definition: pix.h:1339
l_int32 n
Definition: pix.h:660
l_uint32 refcount
Definition: pix.h:601
l_int32 xres
Definition: pix.h:619
l_int32 depth
Definition: pix.h:158
l_int32 strip
Definition: pix.h:571
Definition: pix.h:597
l_int32 w
Definition: pix.h:635
l_int32 nalloc
Definition: pix.h:159
l_uint32 refcount
Definition: pix.h:458
l_int32 n
Definition: pix.h:456
Definition: pix.h:492
l_int32 nalloc
Definition: pix.h:600
Definition: pix.h:562
l_int32 h
Definition: pix.h:568
l_int32 d
Definition: pix.h:637
l_uint8 blue
Definition: pix.h:171
l_int32 h
Definition: pix.h:636
Definition: pix.h:853
Definition: pix.h:502
l_int32 nalloc
Definition: pix.h:505
l_uint32 d
Definition: pix.h:138
l_int32 wpl
Definition: pix.h:586
l_uint32 h
Definition: pix.h:137
static const l_float32 L_GREEN_WEIGHT
Definition: pix.h:244
char * text
Definition: pix.h:148
static const l_float32 L_BLUE_WEIGHT
Definition: pix.h:245
l_int32 xoverlap
Definition: pix.h:569
l_int32 nalloc
Definition: pix.h:495
l_int32 nalloc
Definition: pix.h:535
struct Pix * pix
Definition: pix.h:564
l_int32 w
Definition: pix.h:484
l_int32 offset
Definition: pix.h:550
Definition: pix.h:532
l_int32 ny
Definition: pix.h:566
Definition: pix.h:546
l_int32 yres
Definition: pix.h:590
struct Pix ** pix
Definition: pix.h:459
l_int32 nalloc
Definition: pix.h:661
l_int32 xres
Definition: pix.h:638
l_uint8 green
Definition: pix.h:172
Definition: pix.h:169
l_int32 yoverlap
Definition: pix.h:570
Definition: pix.h:658
l_int32 nalloc
Definition: pix.h:457
l_int32 n
Definition: pix.h:467
l_int32 w
Definition: pix.h:615
struct Pixa ** pixa
Definition: pix.h:469
struct Pix * pix
Definition: pix.h:552
struct Boxa * boxa
Definition: pix.h:664
l_int32 xres
Definition: pix.h:588
l_int32 x
Definition: pix.h:482
l_float64 * data
Definition: pix.h:623
Definition: pix.h:454
l_float32 * y
Definition: pix.h:522
Definition: pix.h:465
l_int32 h
Definition: pix.h:616
Definition: pix.h:633
l_int32 n
Definition: pix.h:504
l_int32 yres
Definition: pix.h:640
l_int32 w
Definition: pix.h:584
char * text
Definition: pix.h:644
l_int32 h
Definition: pix.h:585
void * array
Definition: pix.h:157
Definition: pix.h:718
l_int32 nalloc
Definition: pix.h:520
l_int32 h
Definition: pix.h:485
l_float32 * data
Definition: pix.h:592
l_int32 nalloc
Definition: pix.h:468
Definition: pix.h:134
Definition: pix.h:719
l_int32 cmapflag
Definition: pix.h:645
l_uint8 * data
Definition: pix.h:646
Definition: pix.h:201
Definition: pix.h:982
l_uint32 wpl
Definition: pix.h:140
l_int32 wpl
Definition: pix.h:617
l_int32 offset
Definition: pix.h:662
struct PixComp ** pixc
Definition: pix.h:663
struct Box ** box
Definition: pix.h:497
l_int32 nx
Definition: pix.h:565
struct Boxa * boxa
Definition: pix.h:470
Definition: pix.h:480
Definition: pix.h:613
l_int32 n
Definition: pix.h:599
l_int32 n
Definition: pix.h:519
l_uint32 spp
Definition: pix.h:139
size_t size
Definition: pix.h:647
Definition: pix.h:517
l_uint32 refcount
Definition: pix.h:521
l_int32 n
Definition: pix.h:534
Definition: pix.h:582
struct Pta ** pta
Definition: pix.h:536