Leptonica  1.82.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 
131 /*-------------------------------------------------------------------------*
132  * Basic Pix *
133  *-------------------------------------------------------------------------*/
134  /* The 'special' field is by default 0, but it can hold integers
135  * that direct non-default actions, e.g., in png and jpeg I/O. */
136 
138 struct Pix
139 {
140  l_uint32 w;
141  l_uint32 h;
142  l_uint32 d;
143  l_uint32 spp;
144  l_uint32 wpl;
145  l_uint32 refcount;
146  l_int32 xres;
148  l_int32 yres;
150  l_int32 informat;
151  l_int32 special;
152  char *text;
154  l_uint32 *data;
155 };
156 typedef struct Pix PIX;
157 
160 {
161  void *array;
162  l_int32 depth;
163  l_int32 nalloc;
164  l_int32 n;
165 };
166 typedef struct PixColormap PIXCMAP;
167 
168 
173 struct RGBA_Quad
174 {
175  l_uint8 blue;
176  l_uint8 green;
177  l_uint8 red;
178  l_uint8 alpha;
179 };
180 typedef struct RGBA_Quad RGBA_QUAD;
181 
182 
183 /*-------------------------------------------------------------------------*
184  * Colors for 32 RGBA *
185  *-------------------------------------------------------------------------*/
186 /* <pre>
187  * Notes:
188  * (1) These are the byte indices for colors in 32 bpp images.
189  * They are used through the GET/SET_DATA_BYTE accessors.
190  * The 4th byte, typically known as the "alpha channel" and used
191  * for blending, is used to a small extent in leptonica.
192  * (2) Do not change these values! If you redefine them, functions
193  * that have the shifts hardcoded for efficiency and conciseness
194  * (instead of using the constants below) will break. These
195  * functions are labelled with "***" next to their names at
196  * the top of the files in which they are defined.
197  * (3) The shifts to extract the red, green, blue and alpha components
198  * from a 32 bit pixel are defined here.
199  * </pre>
200  */
201 
203 enum {
204  COLOR_RED = 0,
208 };
209 
210 static const l_int32 L_RED_SHIFT =
211  8 * (sizeof(l_uint32) - 1 - COLOR_RED); /* 24 */
212 static const l_int32 L_GREEN_SHIFT =
213  8 * (sizeof(l_uint32) - 1 - COLOR_GREEN); /* 16 */
214 static const l_int32 L_BLUE_SHIFT =
215  8 * (sizeof(l_uint32) - 1 - COLOR_BLUE); /* 8 */
216 static const l_int32 L_ALPHA_SHIFT =
217  8 * (sizeof(l_uint32) - 1 - L_ALPHA_CHANNEL); /* 0 */
218 
219 
220 /*-------------------------------------------------------------------------*
221  * Colors for drawing boxes *
222  *-------------------------------------------------------------------------*/
224 enum {
231 };
232 
233 
234 /*-------------------------------------------------------------------------*
235  * Perceptual color weights *
236  *-------------------------------------------------------------------------*/
237 /* <pre>
238  * Notes:
239  * (1) These perceptual weighting factors are ad-hoc, but they do
240  * add up to 1. Unlike, for example, the weighting factors for
241  * converting RGB to luminance, or more specifically to Y in the
242  * YUV colorspace. Those numbers come from the
243  * International Telecommunications Union, via ITU-R.
244  * </pre>
245  */
246 static const l_float32 L_RED_WEIGHT = 0.3f;
247 static const l_float32 L_GREEN_WEIGHT = 0.5f;
248 static const l_float32 L_BLUE_WEIGHT = 0.2f;
251 /*-------------------------------------------------------------------------*
252  * Flags for colormap conversion *
253  *-------------------------------------------------------------------------*/
255 enum {
261 };
262 
263 
264 /*------------------------------------------------------------------------*
265  *!
266  * <pre>
267  * The following operation bit flags have been modified from
268  * Sun's pixrect.h.
269  *
270  * The 'op' in 'rasterop' is represented by an integer
271  * composed with Boolean functions using the set of five integers
272  * given below. The integers, and the op codes resulting from
273  * boolean expressions on them, need only be in the range from 0 to 15.
274  * The function is applied on a per-pixel basis.
275  *
276  * Examples: the op code representing ORing the src and dest
277  * is computed using the bit OR, as PIX_SRC | PIX_DST; the op
278  * code representing XORing src and dest is found from
279  * PIX_SRC ^ PIX_DST; the op code representing ANDing src and dest
280  * is found from PIX_SRC & PIX_DST. Note that
281  * PIX_NOT(PIX_CLR) = PIX_SET, and v.v., as they must be.
282  *
283  * We use the following set of definitions:
284  *
285  * #define PIX_SRC 0xc
286  * #define PIX_DST 0xa
287  * #define PIX_NOT(op) (op) ^ 0xf
288  * #define PIX_CLR 0x0
289  * #define PIX_SET 0xf
290  *
291  * These definitions differ from Sun's, in that Sun left-shifted
292  * each value by 1 pixel, and used the least significant bit as a
293  * flag for the "pseudo-operation" of clipping. We don't need
294  * this bit, because it is both efficient and safe ALWAYS to clip
295  * the rectangles to the src and dest images, which is what we do.
296  * See the notes in rop.h on the general choice of these bit flags.
297  *
298  * [If for some reason you need compatibility with Sun's xview package,
299  * you can adopt the original Sun definitions to avoid redefinition conflicts:
300  *
301  * #define PIX_SRC (0xc << 1)
302  * #define PIX_DST (0xa << 1)
303  * #define PIX_NOT(op) ((op) ^ 0x1e)
304  * #define PIX_CLR (0x0 << 1)
305  * #define PIX_SET (0xf << 1)
306  * ]
307  *
308  * We have, for reference, the following 16 unique op flags:
309  *
310  * PIX_CLR 0000 0x0
311  * PIX_SET 1111 0xf
312  * PIX_SRC 1100 0xc
313  * PIX_DST 1010 0xa
314  * PIX_NOT(PIX_SRC) 0011 0x3
315  * PIX_NOT(PIX_DST) 0101 0x5
316  * PIX_SRC | PIX_DST 1110 0xe
317  * PIX_SRC & PIX_DST 1000 0x8
318  * PIX_SRC ^ PIX_DST 0110 0x6
319  * PIX_NOT(PIX_SRC) | PIX_DST 1011 0xb
320  * PIX_NOT(PIX_SRC) & PIX_DST 0010 0x2
321  * PIX_SRC | PIX_NOT(PIX_DST) 1101 0xd
322  * PIX_SRC & PIX_NOT(PIX_DST) 0100 0x4
323  * PIX_NOT(PIX_SRC | PIX_DST) 0001 0x1
324  * PIX_NOT(PIX_SRC & PIX_DST) 0111 0x7
325  * PIX_NOT(PIX_SRC ^ PIX_DST) 1001 0x9
326  *
327  * </pre>
328  *-------------------------------------------------------------------------*/
329 
330 #define PIX_SRC (0xc)
331 #define PIX_DST (0xa)
332 #define PIX_NOT(op) ((op) ^ 0x0f)
333 #define PIX_CLR (0x0)
334 #define PIX_SET (0xf)
336 #define PIX_PAINT (PIX_SRC | PIX_DST)
337 #define PIX_MASK (PIX_SRC & PIX_DST)
338 #define PIX_SUBTRACT (PIX_DST & PIX_NOT(PIX_SRC))
340 #define PIX_XOR (PIX_SRC ^ PIX_DST)
343 /*-------------------------------------------------------------------------*
344  * <pre>
345  * Important Notes:
346  *
347  * (1) The image data is stored in a single contiguous
348  * array of l_uint32, into which the pixels are packed.
349  * By "packed" we mean that there are no unused bits
350  * between pixels, except for end-of-line padding to
351  * satisfy item (2) below.
352  *
353  * (2) Every image raster line begins on a 32-bit word
354  * boundary within this array.
355  *
356  * (3) Pix image data is stored in 32-bit units, with the
357  * pixels ordered from left to right in the image being
358  * stored in order from the MSB to LSB within the word,
359  * for both big-endian and little-endian machines.
360  * This is the natural ordering for big-endian machines,
361  * as successive bytes are stored and fetched progressively
362  * to the right. However, for little-endians, when storing
363  * we re-order the bytes from this byte stream order, and
364  * reshuffle again for byte access on 32-bit entities.
365  * So if the bytes come in sequence from left to right, we
366  * store them on little-endians in byte order:
367  * 3 2 1 0 7 6 5 4 ...
368  * This MSB to LSB ordering allows left and right shift
369  * operations on 32 bit words to move the pixels properly.
370  *
371  * (4) We use 32 bit pixels for both RGB and RGBA color images.
372  * The A (alpha) byte is ignored in most leptonica functions
373  * operating on color images. Within each 4 byte pixel, the
374  * color samples are ordered from MSB to LSB, as follows:
375  *
376  * | MSB | 2nd MSB | 3rd MSB | LSB |
377  * red green blue alpha
378  * 0 1 2 3 (big-endian)
379  * 3 2 1 0 (little-endian)
380  *
381  * Because we use MSB to LSB ordering within the 32-bit word,
382  * the individual 8-bit samples can be accessed with
383  * GET_DATA_BYTE and SET_DATA_BYTE macros, using the
384  * (implicitly big-ending) ordering
385  * red: byte 0 (MSB)
386  * green: byte 1 (2nd MSB)
387  * blue: byte 2 (3rd MSB)
388  * alpha: byte 3 (LSB)
389  *
390  * The specific color assignment is made in this file,
391  * through the definitions of COLOR_RED, etc. Then the R, G
392  * B and A sample values can be retrieved using
393  * redval = GET_DATA_BYTE(&pixel, COLOR_RED);
394  * greenval = GET_DATA_BYTE(&pixel, COLOR_GREEN);
395  * blueval = GET_DATA_BYTE(&pixel, COLOR_BLUE);
396  * alphaval = GET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL);
397  * and they can be set with
398  * SET_DATA_BYTE(&pixel, COLOR_RED, redval);
399  * SET_DATA_BYTE(&pixel, COLOR_GREEN, greenval);
400  * SET_DATA_BYTE(&pixel, COLOR_BLUE, blueval);
401  * SET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL, alphaval);
402  *
403  * More efficiently, these components can be extracted directly
404  * by shifting and masking, explicitly using the values in
405  * L_RED_SHIFT, etc.:
406  * (pixel32 >> L_RED_SHIFT) & 0xff; (red)
407  * (pixel32 >> L_GREEN_SHIFT) & 0xff; (green)
408  * (pixel32 >> L_BLUE_SHIFT) & 0xff; (blue)
409  * (pixel32 >> L_ALPHA_SHIFT) & 0xff; (alpha)
410  * The functions extractRGBValues() and extractRGBAValues() are
411  * provided to do this. Likewise, the pixels can be set
412  * directly by shifting, using composeRGBPixel() and
413  * composeRGBAPixel().
414  *
415  * All these operations work properly on both big- and little-endians.
416  *
417  * (5) A reference count is held within each pix, giving the
418  * number of ptrs to the pix. When a pixClone() call
419  * is made, the ref count is increased by 1, and
420  * when a pixDestroy() call is made, the reference count
421  * of the pix is decremented. The pix is only destroyed
422  * when the reference count goes to zero.
423  *
424  * (6) The version numbers (below) are used in the serialization
425  * of these data structures. They are placed in the files,
426  * and rarely (if ever) change.
427  *
428  * (7) The serialization dependencies are as follows:
429  * pixaa : pixa : boxa
430  * boxaa : boxa
431  * So, for example, pixaa and boxaa can be changed without
432  * forcing a change in pixa or boxa. However, if pixa is
433  * changed, it forces a change in pixaa, and if boxa is
434  * changed, if forces a change in the other three.
435  * We define four version numbers:
436  * PIXAA_VERSION_NUMBER
437  * PIXA_VERSION_NUMBER
438  * BOXAA_VERSION_NUMBER
439  * BOXA_VERSION_NUMBER
440  * </pre>
441  *-------------------------------------------------------------------------*/
442 
443 
444 
445 /*-------------------------------------------------------------------------*
446  * Array of pix *
447  *-------------------------------------------------------------------------*/
448  /* Serialization for primary data structures */
449 #define PIXAA_VERSION_NUMBER 2
450 #define PIXA_VERSION_NUMBER 2
451 #define BOXA_VERSION_NUMBER 2
452 #define BOXAA_VERSION_NUMBER 3
455 struct Pixa
456 {
457  l_int32 n;
458  l_int32 nalloc;
459  l_uint32 refcount;
460  struct Pix **pix;
461  struct Boxa *boxa;
462 };
463 typedef struct Pixa PIXA;
464 
466 struct Pixaa
467 {
468  l_int32 n;
469  l_int32 nalloc;
470  struct Pixa **pixa;
471  struct Boxa *boxa;
472 };
473 typedef struct Pixaa PIXAA;
474 
475 
476 /*-------------------------------------------------------------------------*
477  * Basic rectangle and rectangle arrays *
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;
487 };
488 typedef struct Box BOX;
489 
491 struct Boxa
492 {
493  l_int32 n;
494  l_int32 nalloc;
495  l_uint32 refcount;
496  struct Box **box;
497 };
498 typedef struct Boxa BOXA;
499 
501 struct Boxaa
502 {
503  l_int32 n;
504  l_int32 nalloc;
505  struct Boxa **boxa;
506 };
507 typedef struct Boxaa BOXAA;
508 
509 
510 /*-------------------------------------------------------------------------*
511  * Array of points *
512  *-------------------------------------------------------------------------*/
513 #define PTA_VERSION_NUMBER 1
516 struct Pta
517 {
518  l_int32 n;
519  l_int32 nalloc;
520  l_uint32 refcount;
521  l_float32 *x, *y;
522 };
523 typedef struct Pta PTA;
524 
525 
526 /*-------------------------------------------------------------------------*
527  * Array of Pta *
528  *-------------------------------------------------------------------------*/
530 struct Ptaa
531 {
532  l_int32 n;
533  l_int32 nalloc;
534  struct Pta **pta;
535 };
536 typedef struct Ptaa PTAA;
537 
538 
539 /*-------------------------------------------------------------------------*
540  * Pix accumulator container *
541  *-------------------------------------------------------------------------*/
543 struct Pixacc
544 {
545  l_int32 w;
546  l_int32 h;
547  l_int32 offset;
549  struct Pix *pix;
550 };
551 typedef struct Pixacc PIXACC;
552 
553 
554 /*-------------------------------------------------------------------------*
555  * Pix tiling *
556  *-------------------------------------------------------------------------*/
558 struct PixTiling
559 {
560  struct Pix *pix;
561  l_int32 nx;
562  l_int32 ny;
563  l_int32 w;
564  l_int32 h;
565  l_int32 xoverlap;
566  l_int32 yoverlap;
567  l_int32 strip;
568 };
569 typedef struct PixTiling PIXTILING;
570 
571 
572 /*-------------------------------------------------------------------------*
573  * FPix: pix with float array *
574  *-------------------------------------------------------------------------*/
575 #define FPIX_VERSION_NUMBER 2
578 struct FPix
579 {
580  l_int32 w;
581  l_int32 h;
582  l_int32 wpl;
583  l_uint32 refcount;
584  l_int32 xres;
586  l_int32 yres;
588  l_float32 *data;
589 };
590 typedef struct FPix FPIX;
591 
593 struct FPixa
594 {
595  l_int32 n;
596  l_int32 nalloc;
597  l_uint32 refcount;
598  struct FPix **fpix;
599 };
600 typedef struct FPixa FPIXA;
601 
602 
603 /*-------------------------------------------------------------------------*
604  * DPix: pix with double array *
605  *-------------------------------------------------------------------------*/
606 #define DPIX_VERSION_NUMBER 2
609 struct DPix
610 {
611  l_int32 w;
612  l_int32 h;
613  l_int32 wpl;
614  l_uint32 refcount;
615  l_int32 xres;
617  l_int32 yres;
619  l_float64 *data;
620 };
621 typedef struct DPix DPIX;
622 
623 
624 /*-------------------------------------------------------------------------*
625  * PixComp: compressed pix *
626  *-------------------------------------------------------------------------*/
628 struct PixComp
629 {
630  l_int32 w;
631  l_int32 h;
632  l_int32 d;
633  l_int32 xres;
635  l_int32 yres;
637  l_int32 comptype;
639  char *text;
640  l_int32 cmapflag;
641  l_uint8 *data;
642  size_t size;
643 };
644 typedef struct PixComp PIXC;
645 
646 
647 /*-------------------------------------------------------------------------*
648  * PixaComp: array of compressed pix *
649  *-------------------------------------------------------------------------*/
650 #define PIXACOMP_VERSION_NUMBER 2
653 struct PixaComp
654 {
655  l_int32 n;
656  l_int32 nalloc;
657  l_int32 offset;
658  struct PixComp **pixc;
659  struct Boxa *boxa;
660 };
661 typedef struct PixaComp PIXAC;
662 
663 
664 /*-------------------------------------------------------------------------*
665  * Access and storage flags *
666  *-------------------------------------------------------------------------*/
667 /*
668  * <pre>
669  * For Pix, Box, Pta and Numa, there are 3 standard methods for handling
670  * the retrieval or insertion of a struct:
671  * (1) direct insertion (Don't do this if there is another handle
672  * somewhere to this same struct!)
673  * (2) copy (Always safe, sets up a refcount of 1 on the new object.
674  * Can be undesirable if very large, such as an image or
675  * an array of images.)
676  * (3) clone (Makes another handle to the same struct, and bumps the
677  * refcount up by 1. OK to use except in two situations:
678  * (a) You change data through one of the handles but don't
679  * want those changes to be seen by the other handle.
680  * (b) The application is multi-threaded. Because the clone
681  * operation is not atomic (e.g., locked with a mutex),
682  * it is possible to end up with an incorrect ref count,
683  * causing either a memory leak or a crash.
684  *
685  * For Pixa and Boxa, which are structs that hold an array of clonable
686  * structs, there is an additional method:
687  * (4) copy-clone (Makes a new higher-level struct with a refcount
688  * of 1, but clones all the structs in the array.)
689  *
690  * Unlike the other structs, when retrieving a string from an Sarray,
691  * you are allowed to get a handle without a copy or clone (i.e., the
692  * string is not owned by the handle). You must not either free the string
693  * or insert it in some other struct that would own it. Specifically,
694  * for an Sarray, the copyflag for retrieval is either:
695  * L_COPY or L_NOCOPY
696  * and for insertion, the copyflag is either:
697  * L_COPY or one of {L_INSERT , L_NOCOPY} (the latter are equivalent
698  * for insertion))
699  * Typical patterns are:
700  * (1) Reference a string in an Sarray with L_NOCOPY and insert a copy
701  * of it in another Sarray with L_COPY.
702  * (2) Copy a string from an Sarray with L_COPY and insert it in
703  * another Sarray with L_INSERT (or L_NOCOPY).
704  * In both cases, a copy is made and both Sarrays own their instance
705  * of that string.
706  * </pre>
707  */
709 enum {
710  L_NOCOPY = 0,
712  L_COPY = 1,
713  L_CLONE = 2,
716 };
717 
718 /*----------------------------------------------------------------------------*
719  * Sort flags *
720  *----------------------------------------------------------------------------*/
722 enum {
725 };
726 
728 enum {
731 };
732 
734 enum {
746 };
747 
748 /*---------------------------------------------------------------------------*
749  * Blend flags *
750  *---------------------------------------------------------------------------*/
752 enum {
759 };
760 
762 enum {
765 };
766 
767 /*-------------------------------------------------------------------------*
768  * Graphics pixel setting *
769  *-------------------------------------------------------------------------*/
771 enum {
775 };
776 
777 /*-------------------------------------------------------------------------*
778  * Size and location filter flags *
779  *-------------------------------------------------------------------------*/
781 enum {
786 };
787 
789 enum {
796 };
797 
799 enum {
808 };
809 
811 enum {
815 };
816 
817 /*-------------------------------------------------------------------------*
818  * Color component selection flags *
819  *-------------------------------------------------------------------------*/
821 enum {
831 };
832 
833 /*-------------------------------------------------------------------------*
834  * Color content flags *
835  *-------------------------------------------------------------------------*/
837 enum {
841 };
842 
843 /*-------------------------------------------------------------------------*
844  * 16-bit conversion flags *
845  *-------------------------------------------------------------------------*/
847 enum {
848  L_LS_BYTE = 1,
849  L_MS_BYTE = 2,
855 };
856 
857 /*-------------------------------------------------------------------------*
858  * Rotate and shear flags *
859  *-------------------------------------------------------------------------*/
861 enum {
865 };
866 
868 enum {
871 };
872 
874 enum {
877 };
878 
879 /*-------------------------------------------------------------------------*
880  * Affine transform order flags *
881  *-------------------------------------------------------------------------*/
883 enum {
890 };
891 
892 /*-------------------------------------------------------------------------*
893  * Grayscale filling flags *
894  *-------------------------------------------------------------------------*/
896 enum {
899 };
900 
901 /*-------------------------------------------------------------------------*
902  * Flags for setting to white or black *
903  *-------------------------------------------------------------------------*/
905 enum {
908 };
909 
910 /*-------------------------------------------------------------------------*
911  * Flags for getting white or black value *
912  *-------------------------------------------------------------------------*/
914 enum {
917 };
918 
919 /*-------------------------------------------------------------------------*
920  * Flags for 8 bit and 16 bit pixel sums *
921  *-------------------------------------------------------------------------*/
923 enum {
926 };
927 
928 /*-------------------------------------------------------------------------*
929  * Dither parameters *
930  * If within this grayscale distance from black or white, *
931  * do not propagate excess or deficit to neighboring pixels. *
932  *-------------------------------------------------------------------------*/
934 enum {
939 };
940 
941 /*-------------------------------------------------------------------------*
942  * Distance type flags *
943  *-------------------------------------------------------------------------*/
945 enum {
948 };
949 
950 /*-------------------------------------------------------------------------*
951  * Distance Value flags *
952  *-------------------------------------------------------------------------*/
954 enum {
959  L_ZERO = 5,
960  L_ALL = 6
961 };
962 
963 /*-------------------------------------------------------------------------*
964  * Statistical measures *
965  *-------------------------------------------------------------------------*/
967 enum {
975 };
976 
977 /*-------------------------------------------------------------------------*
978  * Set index selection flags *
979  *-------------------------------------------------------------------------*/
981 enum {
984 };
985 
986 /*-------------------------------------------------------------------------*
987  * Text orientation flags *
988  *-------------------------------------------------------------------------*/
990 enum {
996 };
997 
998 /*-------------------------------------------------------------------------*
999  * Edge orientation flags *
1000  *-------------------------------------------------------------------------*/
1002 enum {
1006 };
1007 
1008 /*-------------------------------------------------------------------------*
1009  * Line orientation flags *
1010  *-------------------------------------------------------------------------*/
1012 enum {
1018 };
1019 
1020 /*-------------------------------------------------------------------------*
1021  * Image orientation flags *
1022  *-------------------------------------------------------------------------*/
1024 enum {
1027 };
1028 
1029 /*-------------------------------------------------------------------------*
1030  * Scan direction flags *
1031  *-------------------------------------------------------------------------*/
1033 enum {
1043 };
1044 
1045 /*-------------------------------------------------------------------------*
1046  * Box size adjustment and location flags *
1047  *-------------------------------------------------------------------------*/
1049 enum {
1061  L_SET_TOP = 11,
1062  L_SET_BOT = 12,
1063  L_GET_LEFT = 13,
1065  L_GET_TOP = 15,
1067 };
1068 
1069 /*-------------------------------------------------------------------------*
1070  * Flags for modifying box boundaries using a second box *
1071  *-------------------------------------------------------------------------*/
1073 enum {
1080 };
1081 
1082 /*-------------------------------------------------------------------------*
1083  * Handling overlapping bounding boxes in boxa *
1084  *-------------------------------------------------------------------------*/
1086 enum {
1089 };
1090 
1091 /*-------------------------------------------------------------------------*
1092  * Selecting or making a box from two (intersecting) boxes *
1093  *-------------------------------------------------------------------------*/
1095 enum {
1100 };
1101 
1102 /*-------------------------------------------------------------------------*
1103  * Flags for replacing invalid boxes *
1104  *-------------------------------------------------------------------------*/
1106 enum {
1109 };
1110 
1111 /*-------------------------------------------------------------------------*
1112  * Flags for box corners and center *
1113  *-------------------------------------------------------------------------*/
1115 enum {
1121 };
1122 
1123 /*-------------------------------------------------------------------------*
1124  * Horizontal warp *
1125  *-------------------------------------------------------------------------*/
1127 enum {
1130 };
1131 
1133 enum {
1136 };
1137 
1138 /*-------------------------------------------------------------------------*
1139  * Pixel selection for resampling *
1140  *-------------------------------------------------------------------------*/
1142 enum {
1145 };
1146 
1147 /*-------------------------------------------------------------------------*
1148  * Thinning flags *
1149  *-------------------------------------------------------------------------*/
1151 enum {
1154 };
1155 
1156 /*-------------------------------------------------------------------------*
1157  * Runlength flags *
1158  *-------------------------------------------------------------------------*/
1160 enum {
1163 };
1164 
1165 /*-------------------------------------------------------------------------*
1166  * Edge filter flags *
1167  *-------------------------------------------------------------------------*/
1169 enum {
1172 };
1173 
1174 /*-------------------------------------------------------------------------*
1175  * Subpixel color component ordering in LCD display *
1176  *-------------------------------------------------------------------------*/
1178 enum {
1183 };
1184 
1185 /*-------------------------------------------------------------------------*
1186  * HSV histogram flags *
1187  *-------------------------------------------------------------------------*/
1189 enum {
1193 };
1194 
1195 /*-------------------------------------------------------------------------*
1196  * HSV Region flags (inclusion, exclusion) *
1197  *-------------------------------------------------------------------------*/
1199 enum {
1202 };
1203 
1204 /*-------------------------------------------------------------------------*
1205  * Location flags for adding text to a pix *
1206  *-------------------------------------------------------------------------*/
1208 enum {
1217 };
1218 
1219 /*-------------------------------------------------------------------------*
1220  * Flags for plotting on a pix *
1221  *-------------------------------------------------------------------------*/
1223 enum {
1230 };
1231 
1232 /*-------------------------------------------------------------------------*
1233  * Flags for making simple masks *
1234  *-------------------------------------------------------------------------*/
1236 enum {
1239 };
1240 
1241 /*-------------------------------------------------------------------------*
1242  * Flags for selecting display program *
1243  *-------------------------------------------------------------------------*/
1245 enum {
1251 };
1252 
1253 /*-------------------------------------------------------------------------*
1254  * Flag(s) used in the 'special' pix field for non-default operations *
1255  * - 0 is default for chroma sampling in jpeg *
1256  * - 10-19 are used for zlib compression in png write *
1257  * - 4 and 8 are used for specifying connectivity in labelling *
1258  *-------------------------------------------------------------------------*/
1260 enum {
1262 };
1263 
1264 /*-------------------------------------------------------------------------*
1265  * Handling negative values in conversion to unsigned int *
1266  *-------------------------------------------------------------------------*/
1268 enum {
1271 };
1272 
1273 /*-------------------------------------------------------------------------*
1274  * Relative to zero flags *
1275  *-------------------------------------------------------------------------*/
1277 enum {
1281 };
1282 
1283 /*-------------------------------------------------------------------------*
1284  * Flags for adding or removing trailing slash from string *
1285  *-------------------------------------------------------------------------*/
1287 enum {
1290 };
1291 
1292 /*-------------------------------------------------------------------------*
1293  * Pix allocator and deallocator function types *
1294  *-------------------------------------------------------------------------*/
1296 typedef void *(*alloc_fn)(size_t);
1297 
1299 typedef void (*dealloc_fn)(void *);
1300 
1301 #endif /* LEPTONICA_PIX_H */
l_uint8 alpha
Definition: pix.h:178
l_int32 xres
Definition: pix.h:146
l_uint32 * data
Definition: pix.h:154
l_int32 n
Definition: pix.h:493
l_uint32 refcount
Definition: pix.h:614
l_uint32 refcount
Definition: pix.h:495
struct FPix ** fpix
Definition: pix.h:598
l_uint32 w
Definition: pix.h:140
l_int32 w
Definition: pix.h:545
l_int32 special
Definition: pix.h:151
struct Boxa * boxa
Definition: pix.h:461
Definition: pix.h:204
l_int32 n
Definition: pix.h:164
l_int32 yres
Definition: pix.h:617
l_int32 informat
Definition: pix.h:150
Definition: pix.h:713
l_uint32 refcount
Definition: pix.h:583
l_int32 h
Definition: pix.h:546
Definition: pix.h:849
static const l_float32 L_RED_WEIGHT
Definition: pix.h:246
l_uint32 refcount
Definition: pix.h:486
l_uint32 refcount
Definition: pix.h:145
Definition: pix.h:712
l_int32 yres
Definition: pix.h:148
l_int32 w
Definition: pix.h:563
struct PixColormap * colormap
Definition: pix.h:153
l_int32 y
Definition: pix.h:483
l_int32 comptype
Definition: pix.h:637
Definition: pix.h:710
struct Boxa ** boxa
Definition: pix.h:505
l_uint8 red
Definition: pix.h:177
void(* dealloc_fn)(void *)
Definition: pix.h:1299
l_int32 n
Definition: pix.h:655
l_uint32 refcount
Definition: pix.h:597
l_int32 xres
Definition: pix.h:615
l_int32 depth
Definition: pix.h:162
l_int32 strip
Definition: pix.h:567
Definition: pix.h:593
l_int32 w
Definition: pix.h:630
l_int32 nalloc
Definition: pix.h:163
l_uint32 refcount
Definition: pix.h:459
l_int32 n
Definition: pix.h:457
Definition: pix.h:491
l_int32 nalloc
Definition: pix.h:596
Definition: pix.h:558
l_int32 h
Definition: pix.h:564
l_int32 d
Definition: pix.h:632
l_uint8 blue
Definition: pix.h:175
l_int32 h
Definition: pix.h:631
Definition: pix.h:501
l_int32 nalloc
Definition: pix.h:504
Definition: pix.h:848
l_uint32 d
Definition: pix.h:142
l_int32 wpl
Definition: pix.h:582
l_uint32 h
Definition: pix.h:141
static const l_float32 L_GREEN_WEIGHT
Definition: pix.h:247
char * text
Definition: pix.h:152
static const l_float32 L_BLUE_WEIGHT
Definition: pix.h:248
l_int32 xoverlap
Definition: pix.h:565
l_int32 nalloc
Definition: pix.h:494
l_int32 nalloc
Definition: pix.h:533
struct Pix * pix
Definition: pix.h:560
l_int32 w
Definition: pix.h:484
l_int32 offset
Definition: pix.h:547
Definition: pix.h:530
l_int32 ny
Definition: pix.h:562
Definition: pix.h:543
l_int32 yres
Definition: pix.h:586
struct Pix ** pix
Definition: pix.h:460
l_int32 nalloc
Definition: pix.h:656
l_int32 xres
Definition: pix.h:633
l_uint8 green
Definition: pix.h:176
Definition: pix.h:173
l_int32 yoverlap
Definition: pix.h:566
Definition: pix.h:653
l_int32 nalloc
Definition: pix.h:458
l_int32 n
Definition: pix.h:468
l_int32 w
Definition: pix.h:611
struct Pixa ** pixa
Definition: pix.h:470
struct Pix * pix
Definition: pix.h:549
Definition: pix.h:711
struct Boxa * boxa
Definition: pix.h:659
l_int32 xres
Definition: pix.h:584
l_int32 x
Definition: pix.h:482
l_float64 * data
Definition: pix.h:619
Definition: pix.h:455
l_float32 * y
Definition: pix.h:521
Definition: pix.h:466
l_int32 h
Definition: pix.h:612
Definition: pix.h:628
l_int32 n
Definition: pix.h:503
l_int32 yres
Definition: pix.h:635
l_int32 w
Definition: pix.h:580
char * text
Definition: pix.h:639
l_int32 h
Definition: pix.h:581
Definition: pix.h:959
void * array
Definition: pix.h:161
l_int32 nalloc
Definition: pix.h:519
l_int32 h
Definition: pix.h:485
Definition: pix.h:960
l_float32 * data
Definition: pix.h:588
l_int32 nalloc
Definition: pix.h:469
Definition: pix.h:138
l_int32 cmapflag
Definition: pix.h:640
l_uint8 * data
Definition: pix.h:641
l_uint32 wpl
Definition: pix.h:144
l_int32 wpl
Definition: pix.h:613
l_int32 offset
Definition: pix.h:657
struct PixComp ** pixc
Definition: pix.h:658
struct Box ** box
Definition: pix.h:496
l_int32 nx
Definition: pix.h:561
struct Boxa * boxa
Definition: pix.h:471
Definition: pix.h:480
Definition: pix.h:609
l_int32 n
Definition: pix.h:595
l_int32 n
Definition: pix.h:518
l_uint32 spp
Definition: pix.h:143
size_t size
Definition: pix.h:642
Definition: pix.h:516
l_uint32 refcount
Definition: pix.h:520
l_int32 n
Definition: pix.h:532
Definition: pix.h:578
struct Pta ** pta
Definition: pix.h:534