motion-ocr 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +10 -0
  4. data/LICENSE +28 -0
  5. data/README.md +22 -0
  6. data/Rakefile +17 -0
  7. data/app/app_delegate.rb +2 -0
  8. data/lib/motion-ocr.rb +26 -0
  9. data/lib/motion-ocr/version.rb +3 -0
  10. data/motion-ocr.gemspec +20 -0
  11. data/resources/tessdata/configs/nodict +3 -0
  12. data/resources/tessdata/eng.traineddata +0 -0
  13. data/spec/motion_ocr_spec.rb +23 -0
  14. data/spec/support/phototest.gif +0 -0
  15. data/vendor/MotionOCR/MotionOCR.bridgesupport +14722 -0
  16. data/vendor/MotionOCR/MotionOCR.xcodeproj/project.pbxproj +390 -0
  17. data/vendor/MotionOCR/MotionOCR.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  18. data/vendor/MotionOCR/MotionOCR.xcodeproj/project.xcworkspace/xcuserdata/fer.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  19. data/vendor/MotionOCR/MotionOCR.xcodeproj/xcuserdata/fer.xcuserdatad/xcschemes/MotionOCR.xcscheme +59 -0
  20. data/vendor/MotionOCR/MotionOCR.xcodeproj/xcuserdata/fer.xcuserdatad/xcschemes/xcschememanagement.plist +22 -0
  21. data/vendor/MotionOCR/MotionOCR/MotionOCR-Prefix.pch +7 -0
  22. data/vendor/MotionOCR/MotionOCR/MotionOCR.h +22 -0
  23. data/vendor/MotionOCR/MotionOCR/MotionOCR.mm +89 -0
  24. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/allheaders.h +32 -0
  25. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/alltypes.h +49 -0
  26. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/array.h +125 -0
  27. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/arrayaccess.h +194 -0
  28. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/bbuffer.h +46 -0
  29. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/bmf.h +51 -0
  30. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/bmp.h +74 -0
  31. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/ccbord.h +103 -0
  32. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/dewarp.h +57 -0
  33. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/endianness.h +11 -0
  34. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/environ.h +281 -0
  35. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/freetype.h +23 -0
  36. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/gplot.h +77 -0
  37. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/heap.h +73 -0
  38. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/imageio.h +153 -0
  39. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/jbclass.h +122 -0
  40. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/leptprotos.h +2058 -0
  41. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/leptwin.h +34 -0
  42. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/list.h +76 -0
  43. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/morph.h +218 -0
  44. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/pix.h +945 -0
  45. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/ptra.h +80 -0
  46. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/queue.h +63 -0
  47. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/readbarcode.h +220 -0
  48. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/regutils.h +122 -0
  49. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/stack.h +55 -0
  50. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/sudoku.h +62 -0
  51. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/leptonica/watershed.h +52 -0
  52. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/apitypes.h +31 -0
  53. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/baseapi.h +664 -0
  54. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/errcode.h +104 -0
  55. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/genericvector.h +763 -0
  56. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/helpers.h +139 -0
  57. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/host.h +180 -0
  58. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/ndminx.h +31 -0
  59. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/ocrclass.h +335 -0
  60. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/platform.h +48 -0
  61. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/publictypes.h +202 -0
  62. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/tesscallback.h +1238 -0
  63. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/thresholder.h +170 -0
  64. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/include/tesseract/unichar.h +85 -0
  65. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/lib/liblept.a +0 -0
  66. data/vendor/MotionOCR/MotionOCR/build_dependencies/dependencies/lib/libtesseract_all.a +0 -0
  67. metadata +113 -0
@@ -0,0 +1,34 @@
1
+ /*====================================================================*
2
+ - Copyright (C) 2010 Leptonica. All rights reserved.
3
+ - This software is distributed in the hope that it will be
4
+ - useful, but with NO WARRANTY OF ANY KIND.
5
+ - No author or distributor accepts responsibility to anyone for the
6
+ - consequences of using this software, or for whether it serves any
7
+ - particular purpose or works at all, unless he or she says so in
8
+ - writing. Everyone is granted permission to copy, modify and
9
+ - redistribute this source code, for commercial or non-commercial
10
+ - purposes, with the following restrictions: (1) the origin of this
11
+ - source code must not be misrepresented; (2) modified versions must
12
+ - be plainly marked as such; and (3) this notice may not be removed
13
+ - or altered from any source or modified source distribution.
14
+ *====================================================================*/
15
+
16
+ #ifdef _WIN32
17
+ #ifndef LEPTONICA_LEPTWIN_H
18
+ #define LEPTONICA_LEPTWIN_H
19
+
20
+ #include "allheaders.h"
21
+ #include <windows.h>
22
+
23
+ #ifdef __cplusplus
24
+ extern "C" {
25
+ #endif /* __cplusplus */
26
+
27
+ LEPT_DLL extern HBITMAP pixGetWindowsHBITMAP( PIX *pixs );
28
+
29
+ #ifdef __cplusplus
30
+ }
31
+ #endif /* __cplusplus */
32
+
33
+ #endif /* LEPTONICA_LEPTWIN_H */
34
+ #endif /* _WIN32 */
@@ -0,0 +1,76 @@
1
+
2
+ /*====================================================================*
3
+ - Copyright (C) 2001 Leptonica. All rights reserved.
4
+ - This software is distributed in the hope that it will be
5
+ - useful, but with NO WARRANTY OF ANY KIND.
6
+ - No author or distributor accepts responsibility to anyone for the
7
+ - consequences of using this software, or for whether it serves any
8
+ - particular purpose or works at all, unless he or she says so in
9
+ - writing. Everyone is granted permission to copy, modify and
10
+ - redistribute this source code, for commercial or non-commercial
11
+ - purposes, with the following restrictions: (1) the origin of this
12
+ - source code must not be misrepresented; (2) modified versions must
13
+ - be plainly marked as such; and (3) this notice may not be removed
14
+ - or altered from any source or modified source distribution.
15
+ *====================================================================*/
16
+
17
+ #ifndef LEPTONICA_LIST_H
18
+ #define LEPTONICA_LIST_H
19
+
20
+ /*
21
+ * list.h
22
+ *
23
+ * Cell for double-linked lists
24
+ *
25
+ * This allows composition of a list of cells with
26
+ * prev, next and data pointers. Generic data
27
+ * structures hang on the list cell data pointers.
28
+ *
29
+ * The list is not circular because that would add much
30
+ * complexity in traversing the list under general
31
+ * conditions where list cells can be added and removed.
32
+ * The only disadvantage of not having the head point to
33
+ * the last cell is that the list must be traversed to
34
+ * find its tail. However, this traversal is fast, and
35
+ * the listRemoveFromTail() function updates the tail
36
+ * so there is no searching overhead with repeated use.
37
+ *
38
+ * The list macros are used to run through a list, and their
39
+ * use is encouraged. They are invoked, e.g., as
40
+ *
41
+ * DLLIST *head, *elem;
42
+ * ...
43
+ * L_BEGIN_LIST_FORWARD(head, elem)
44
+ * <do something with elem and/or elem->data >
45
+ * L_END_LIST
46
+ *
47
+ */
48
+
49
+ struct DoubleLinkedList
50
+ {
51
+ struct DoubleLinkedList *prev;
52
+ struct DoubleLinkedList *next;
53
+ void *data;
54
+ };
55
+ typedef struct DoubleLinkedList DLLIST;
56
+
57
+
58
+ /* Simple list traverse macros */
59
+ #define L_BEGIN_LIST_FORWARD(head, element) \
60
+ { \
61
+ DLLIST *_leptvar_nextelem_; \
62
+ for ((element) = (head); (element); (element) = _leptvar_nextelem_) { \
63
+ _leptvar_nextelem_ = (element)->next;
64
+
65
+
66
+ #define L_BEGIN_LIST_REVERSE(tail, element) \
67
+ { \
68
+ DLLIST *_leptvar_prevelem_; \
69
+ for ((element) = (tail); (element); (element) = _leptvar_prevelem_) { \
70
+ _leptvar_prevelem_ = (element)->prev;
71
+
72
+
73
+ #define L_END_LIST }}
74
+
75
+
76
+ #endif /* LEPTONICA_LIST_H */
@@ -0,0 +1,218 @@
1
+ /*====================================================================*
2
+ - Copyright (C) 2001 Leptonica. All rights reserved.
3
+ - This software is distributed in the hope that it will be
4
+ - useful, but with NO WARRANTY OF ANY KIND.
5
+ - No author or distributor accepts responsibility to anyone for the
6
+ - consequences of using this software, or for whether it serves any
7
+ - particular purpose or works at all, unless he or she says so in
8
+ - writing. Everyone is granted permission to copy, modify and
9
+ - redistribute this source code, for commercial or non-commercial
10
+ - purposes, with the following restrictions: (1) the origin of this
11
+ - source code must not be misrepresented; (2) modified versions must
12
+ - be plainly marked as such; and (3) this notice may not be removed
13
+ - or altered from any source or modified source distribution.
14
+ *====================================================================*/
15
+
16
+ #ifndef LEPTONICA_MORPH_H
17
+ #define LEPTONICA_MORPH_H
18
+
19
+ /*
20
+ * morph.h
21
+ *
22
+ * Contains the following structs:
23
+ * struct Sel
24
+ * struct Sela
25
+ * struct Kernel
26
+ *
27
+ * Contains definitions for:
28
+ * morphological b.c. flags
29
+ * structuring element types
30
+ * runlength flags for granulometry
31
+ * direction flags for grayscale morphology
32
+ * morphological operation flags
33
+ * standard border size
34
+ * grayscale intensity scaling flags
35
+ * morphological tophat flags
36
+ * arithmetic and logical operator flags
37
+ * grayscale morphology selection flags
38
+ * distance function b.c. flags
39
+ * image comparison flags
40
+ * color content flags
41
+ */
42
+
43
+ /*-------------------------------------------------------------------------*
44
+ * Sel and Sel array *
45
+ *-------------------------------------------------------------------------*/
46
+ #define SEL_VERSION_NUMBER 1
47
+
48
+ struct Sel
49
+ {
50
+ l_int32 sy; /* sel height */
51
+ l_int32 sx; /* sel width */
52
+ l_int32 cy; /* y location of sel origin */
53
+ l_int32 cx; /* x location of sel origin */
54
+ l_int32 **data; /* {0,1,2}; data[i][j] in [row][col] order */
55
+ char *name; /* used to find sel by name */
56
+ };
57
+ typedef struct Sel SEL;
58
+
59
+ struct Sela
60
+ {
61
+ l_int32 n; /* number of sel actually stored */
62
+ l_int32 nalloc; /* size of allocated ptr array */
63
+ struct Sel **sel; /* sel ptr array */
64
+ };
65
+ typedef struct Sela SELA;
66
+
67
+
68
+ /*-------------------------------------------------------------------------*
69
+ * Kernel *
70
+ *-------------------------------------------------------------------------*/
71
+ #define KERNEL_VERSION_NUMBER 2
72
+
73
+ struct L_Kernel
74
+ {
75
+ l_int32 sy; /* kernel height */
76
+ l_int32 sx; /* kernel width */
77
+ l_int32 cy; /* y location of kernel origin */
78
+ l_int32 cx; /* x location of kernel origin */
79
+ l_float32 **data; /* data[i][j] in [row][col] order */
80
+ };
81
+ typedef struct L_Kernel L_KERNEL;
82
+
83
+
84
+ /*-------------------------------------------------------------------------*
85
+ * Morphological boundary condition flags *
86
+ *
87
+ * Two types of boundary condition for erosion.
88
+ * The global variable MORPH_BC takes on one of these two values.
89
+ * See notes in morph.c for usage.
90
+ *-------------------------------------------------------------------------*/
91
+ enum {
92
+ SYMMETRIC_MORPH_BC = 0,
93
+ ASYMMETRIC_MORPH_BC = 1
94
+ };
95
+
96
+
97
+ /*-------------------------------------------------------------------------*
98
+ * Structuring element types *
99
+ *-------------------------------------------------------------------------*/
100
+ enum {
101
+ SEL_DONT_CARE = 0,
102
+ SEL_HIT = 1,
103
+ SEL_MISS = 2
104
+ };
105
+
106
+
107
+ /*-------------------------------------------------------------------------*
108
+ * Runlength flags for granulometry *
109
+ *-------------------------------------------------------------------------*/
110
+ enum {
111
+ L_RUN_OFF = 0,
112
+ L_RUN_ON = 1
113
+ };
114
+
115
+
116
+ /*-------------------------------------------------------------------------*
117
+ * Direction flags for grayscale morphology, granulometry, *
118
+ * composable Sels, and convolution *
119
+ *-------------------------------------------------------------------------*/
120
+ enum {
121
+ L_HORIZ = 1,
122
+ L_VERT = 2,
123
+ L_BOTH_DIRECTIONS = 3
124
+ };
125
+
126
+
127
+ /*-------------------------------------------------------------------------*
128
+ * Morphological operation flags *
129
+ *-------------------------------------------------------------------------*/
130
+ enum {
131
+ L_MORPH_DILATE = 1,
132
+ L_MORPH_ERODE = 2,
133
+ L_MORPH_OPEN = 3,
134
+ L_MORPH_CLOSE = 4,
135
+ L_MORPH_HMT = 5
136
+ };
137
+
138
+
139
+ /*-------------------------------------------------------------------------*
140
+ * Grayscale intensity scaling flags *
141
+ *-------------------------------------------------------------------------*/
142
+ enum {
143
+ L_LINEAR_SCALE = 1,
144
+ L_LOG_SCALE = 2
145
+ };
146
+
147
+
148
+ /*-------------------------------------------------------------------------*
149
+ * Morphological tophat flags *
150
+ *-------------------------------------------------------------------------*/
151
+ enum {
152
+ L_TOPHAT_WHITE = 0,
153
+ L_TOPHAT_BLACK = 1
154
+ };
155
+
156
+
157
+ /*-------------------------------------------------------------------------*
158
+ * Arithmetic and logical operator flags *
159
+ * (use on grayscale images and Numas) *
160
+ *-------------------------------------------------------------------------*/
161
+ enum {
162
+ L_ARITH_ADD = 1,
163
+ L_ARITH_SUBTRACT = 2,
164
+ L_ARITH_MULTIPLY = 3, /* on numas only */
165
+ L_ARITH_DIVIDE = 4, /* on numas only */
166
+ L_UNION = 5, /* on numas only */
167
+ L_INTERSECTION = 6, /* on numas only */
168
+ L_SUBTRACTION = 7, /* on numas only */
169
+ L_EXCLUSIVE_OR = 8 /* on numas only */
170
+ };
171
+
172
+
173
+ /*-------------------------------------------------------------------------*
174
+ * Min/max selection flags *
175
+ *-------------------------------------------------------------------------*/
176
+ enum {
177
+ L_CHOOSE_MIN = 1, /* useful in a downscaling "erosion" */
178
+ L_CHOOSE_MAX = 2, /* useful in a downscaling "dilation" */
179
+ L_CHOOSE_MAX_MIN_DIFF = 3 /* useful in a downscaling contrast */
180
+ };
181
+
182
+
183
+ /*-------------------------------------------------------------------------*
184
+ * Distance function b.c. flags *
185
+ *-------------------------------------------------------------------------*/
186
+ enum {
187
+ L_BOUNDARY_BG = 1, /* assume bg outside image */
188
+ L_BOUNDARY_FG = 2 /* assume fg outside image */
189
+ };
190
+
191
+
192
+ /*-------------------------------------------------------------------------*
193
+ * Image comparison flags *
194
+ *-------------------------------------------------------------------------*/
195
+ enum {
196
+ L_COMPARE_XOR = 1,
197
+ L_COMPARE_SUBTRACT = 2,
198
+ L_COMPARE_ABS_DIFF = 3
199
+ };
200
+
201
+
202
+ /*-------------------------------------------------------------------------*
203
+ * Color content flags *
204
+ *-------------------------------------------------------------------------*/
205
+ enum {
206
+ L_MAX_DIFF_FROM_AVERAGE_2 = 1,
207
+ L_MAX_MIN_DIFF_FROM_2 = 2,
208
+ L_MAX_DIFF = 3
209
+ };
210
+
211
+
212
+ /*-------------------------------------------------------------------------*
213
+ * Standard size of border added around images for special processing *
214
+ *-------------------------------------------------------------------------*/
215
+ static const l_int32 ADDED_BORDER = 32; /* pixels, not bits */
216
+
217
+
218
+ #endif /* LEPTONICA_MORPH_H */
@@ -0,0 +1,945 @@
1
+ /*====================================================================*
2
+ - Copyright (C) 2001 Leptonica. All rights reserved.
3
+ - This software is distributed in the hope that it will be
4
+ - useful, but with NO WARRANTY OF ANY KIND.
5
+ - No author or distributor accepts responsibility to anyone for the
6
+ - consequences of using this software, or for whether it serves any
7
+ - particular purpose or works at all, unless he or she says so in
8
+ - writing. Everyone is granted permission to copy, modify and
9
+ - redistribute this source code, for commercial or non-commercial
10
+ - purposes, with the following restrictions: (1) the origin of this
11
+ - source code must not be misrepresented; (2) modified versions must
12
+ - be plainly marked as such; and (3) this notice may not be removed
13
+ - or altered from any source or modified source distribution.
14
+ *====================================================================*/
15
+
16
+ #ifndef LEPTONICA_PIX_H
17
+ #define LEPTONICA_PIX_H
18
+
19
+ /*
20
+ * pix.h
21
+ *
22
+ * Contains the following structures:
23
+ * struct Pix
24
+ * struct PixColormap
25
+ * struct RGBA_Quad
26
+ * struct Pixa
27
+ * struct Pixaa
28
+ * struct Box
29
+ * struct Boxa
30
+ * struct Boxaa
31
+ * struct Pta
32
+ * struct Ptaa
33
+ * struct Pixacc
34
+ * struct PixTiling
35
+ * struct FPix
36
+ * struct FPixa
37
+ * struct DPix
38
+ * struct PixComp
39
+ * struct PixaComp
40
+ *
41
+ * Contains definitions for:
42
+ * Colors for RGB
43
+ * Perceptual color weights
44
+ * Colormap conversion flags
45
+ * Rasterop bit flags
46
+ * Structure access flags (for insert, copy, clone, copy-clone)
47
+ * Sorting flags (by type and direction)
48
+ * Blending flags
49
+ * Graphics pixel setting flags
50
+ * Size filtering flags
51
+ * Color component selection flags
52
+ * Rotation and shear flags
53
+ * Affine transform order flags
54
+ * Grayscale filling flags
55
+ * Flags for setting to white or black
56
+ * Dithering flags
57
+ * Distance flags
58
+ * Statistical measures
59
+ * Set selection flags
60
+ * Text orientation flags
61
+ * Edge orientation flags
62
+ * Line orientation flags
63
+ * Scan direction flags
64
+ * Horizontal warp
65
+ * Pixel selection for resampling
66
+ * Thinning flags
67
+ * Runlength flags
68
+ * Edge filter flags
69
+ * Handling negative values in conversion to unsigned int
70
+ * Subpixel color component ordering in LCD display
71
+ * Relative to zero flags
72
+ * HSV histogram flags
73
+ * Region flags (inclusion, exclusion)
74
+ * Flags for adding text to a pix
75
+ * Flags for selecting display program
76
+ */
77
+
78
+
79
+ /*-------------------------------------------------------------------------*
80
+ * Basic Pix *
81
+ *-------------------------------------------------------------------------*/
82
+ struct Pix
83
+ {
84
+ l_uint32 w; /* width in pixels */
85
+ l_uint32 h; /* height in pixels */
86
+ l_uint32 d; /* depth in bits */
87
+ l_uint32 wpl; /* 32-bit words/line */
88
+ l_uint32 refcount; /* reference count (1 if no clones) */
89
+ l_int32 xres; /* image res (ppi) in x direction */
90
+ /* (use 0 if unknown) */
91
+ l_int32 yres; /* image res (ppi) in y direction */
92
+ /* (use 0 if unknown) */
93
+ l_int32 informat; /* input file format, IFF_* */
94
+ char *text; /* text string associated with pix */
95
+ struct PixColormap *colormap; /* colormap (may be null) */
96
+ l_uint32 *data; /* the image data */
97
+ };
98
+ typedef struct Pix PIX;
99
+
100
+
101
+ struct PixColormap
102
+ {
103
+ void *array; /* colormap table (array of RGBA_QUAD) */
104
+ l_int32 depth; /* of pix (1, 2, 4 or 8 bpp) */
105
+ l_int32 nalloc; /* number of color entries allocated */
106
+ l_int32 n; /* number of color entries used */
107
+ };
108
+ typedef struct PixColormap PIXCMAP;
109
+
110
+
111
+ /* Colormap table entry (after the BMP version).
112
+ * Note that the BMP format stores the colormap table exactly
113
+ * as it appears here, with color samples being stored sequentially,
114
+ * in the order (b,g,r,a). */
115
+ struct RGBA_Quad
116
+ {
117
+ l_uint8 blue;
118
+ l_uint8 green;
119
+ l_uint8 red;
120
+ l_uint8 reserved;
121
+ };
122
+ typedef struct RGBA_Quad RGBA_QUAD;
123
+
124
+
125
+
126
+ /*-------------------------------------------------------------------------*
127
+ * Colors for 32 bpp *
128
+ *-------------------------------------------------------------------------*/
129
+ /* Notes:
130
+ * (1) These are the byte indices for colors in 32 bpp images.
131
+ * They are used through the GET/SET_DATA_BYTE accessors.
132
+ * The 4th byte, typically known as the "alpha channel" and used
133
+ * for blending, is not explicitly used in leptonica.
134
+ * (2) If you redefine these values, functions that have the shifts
135
+ * hardcoded (instead of using the constants below) will break.
136
+ * These functions are labelled with "***" next to their names
137
+ * at the top of the files in which they are defined.
138
+ * Advice: Do not change these values!
139
+ * (3) The shifts to extract the red, green and blue components
140
+ * from a 32 bit pixel are defined in terms of these colors.
141
+ */
142
+ enum {
143
+ COLOR_RED = 0,
144
+ COLOR_GREEN = 1,
145
+ COLOR_BLUE = 2,
146
+ L_ALPHA_CHANNEL = 3
147
+ };
148
+
149
+ static const l_int32 L_RED_SHIFT =
150
+ 8 * (sizeof(l_uint32) - 1 - COLOR_RED); /* 24 */
151
+ static const l_int32 L_GREEN_SHIFT =
152
+ 8 * (sizeof(l_uint32) - 1 - COLOR_GREEN); /* 16 */
153
+ static const l_int32 L_BLUE_SHIFT =
154
+ 8 * (sizeof(l_uint32) - 1 - COLOR_BLUE); /* 8 */
155
+ static const l_int32 L_ALPHA_SHIFT =
156
+ 8 * (sizeof(l_uint32) - 1 - L_ALPHA_CHANNEL); /* 0 */
157
+
158
+
159
+ /*-------------------------------------------------------------------------*
160
+ * Perceptual color weights *
161
+ *-------------------------------------------------------------------------*/
162
+ /* Notes:
163
+ * (1) These numbers are ad-hoc, but they do add up to 1.
164
+ * Unlike, for example, the weighting factor for conversion
165
+ * of RGB to luminance, or more specifically to Y in the
166
+ * YUV colorspace. Those numbers come from the
167
+ * International Telecommunications Union, via ITU-R.
168
+ */
169
+ static const l_float32 L_RED_WEIGHT = 0.3;
170
+ static const l_float32 L_GREEN_WEIGHT = 0.5;
171
+ static const l_float32 L_BLUE_WEIGHT = 0.2;
172
+
173
+
174
+ /*-------------------------------------------------------------------------*
175
+ * Flags for colormap conversion *
176
+ *-------------------------------------------------------------------------*/
177
+ enum {
178
+ REMOVE_CMAP_TO_BINARY = 0,
179
+ REMOVE_CMAP_TO_GRAYSCALE = 1,
180
+ REMOVE_CMAP_TO_FULL_COLOR = 2,
181
+ REMOVE_CMAP_BASED_ON_SRC = 3
182
+ };
183
+
184
+
185
+ /*-------------------------------------------------------------------------*
186
+ *
187
+ * The following operation bit flags have been modified from
188
+ * Sun's pixrect.h.
189
+ *
190
+ * The 'op' in 'rasterop' is represented by an integer
191
+ * composed with Boolean functions using the set of five integers
192
+ * given below. The integers, and the op codes resulting from
193
+ * boolean expressions on them, need only be in the range from 0 to 15.
194
+ * The function is applied on a per-pixel basis.
195
+ *
196
+ * Examples: the op code representing ORing the src and dest
197
+ * is computed using the bit OR, as PIX_SRC | PIX_DST; the op
198
+ * code representing XORing src and dest is found from
199
+ * PIX_SRC ^ PIX_DST; the op code representing ANDing src and dest
200
+ * is found from PIX_SRC & PIX_DST. Note that
201
+ * PIX_NOT(PIX_CLR) = PIX_SET, and v.v., as they must be.
202
+ *
203
+ * We would like to use the following set of definitions:
204
+ *
205
+ * #define PIX_SRC 0xc
206
+ * #define PIX_DST 0xa
207
+ * #define PIX_NOT(op) ((op) ^ 0xf)
208
+ * #define PIX_CLR 0x0
209
+ * #define PIX_SET 0xf
210
+ *
211
+ * Now, these definitions differ from Sun's, in that Sun
212
+ * left-shifted each value by 1 pixel, and used the least
213
+ * significant bit as a flag for the "pseudo-operation" of
214
+ * clipping. We don't need this bit, because it is both
215
+ * efficient and safe ALWAYS to clip the rectangles to the src
216
+ * and dest images, which is what we do. See the notes in rop.h
217
+ * on the general choice of these bit flags.
218
+ *
219
+ * However, if you include Sun's xview package, you will get their
220
+ * definitions, and because I like using these flags, we will
221
+ * adopt the original Sun definitions to avoid redefinition conflicts.
222
+ *
223
+ * Then we have, for reference, the following 16 unique op flags:
224
+ *
225
+ * PIX_CLR 00000 0x0
226
+ * PIX_SET 11110 0x1e
227
+ * PIX_SRC 11000 0x18
228
+ * PIX_DST 10100 0x14
229
+ * PIX_NOT(PIX_SRC) 00110 0x06
230
+ * PIX_NOT(PIX_DST) 01010 0x0a
231
+ * PIX_SRC | PIX_DST 11100 0x1c
232
+ * PIX_SRC & PIX_DST 10000 0x10
233
+ * PIX_SRC ^ PIX_DST 01100 0x0c
234
+ * PIX_NOT(PIX_SRC) | PIX_DST 10110 0x16
235
+ * PIX_NOT(PIX_SRC) & PIX_DST 00100 0x04
236
+ * PIX_SRC | PIX_NOT(PIX_DST) 11010 0x1a
237
+ * PIX_SRC & PIX_NOT(PIX_DST) 01000 0x08
238
+ * PIX_NOT(PIX_SRC | PIX_DST) 00010 0x02
239
+ * PIX_NOT(PIX_SRC & PIX_DST) 01110 0x0e
240
+ * PIX_NOT(PIX_SRC ^ PIX_DST) 10010 0x12
241
+ *
242
+ *-------------------------------------------------------------------------*/
243
+ #define PIX_SRC (0xc << 1)
244
+ #define PIX_DST (0xa << 1)
245
+ #define PIX_NOT(op) ((op) ^ 0x1e)
246
+ #define PIX_CLR (0x0 << 1)
247
+ #define PIX_SET (0xf << 1)
248
+
249
+ #define PIX_PAINT (PIX_SRC | PIX_DST)
250
+ #define PIX_MASK (PIX_SRC & PIX_DST)
251
+ #define PIX_SUBTRACT (PIX_DST & PIX_NOT(PIX_SRC))
252
+ #define PIX_XOR (PIX_SRC ^ PIX_DST)
253
+
254
+
255
+ /*-------------------------------------------------------------------------*
256
+ *
257
+ * Important Notes:
258
+ *
259
+ * (1) The image data is stored in a single contiguous
260
+ * array of l_uint32, into which the pixels are packed.
261
+ * By "packed" we mean that there are no unused bits
262
+ * between pixels, except for end-of-line padding to
263
+ * satisfy item (2) below.
264
+ *
265
+ * (2) Every image raster line begins on a 32-bit word
266
+ * boundary within this array.
267
+ *
268
+ * (3) Pix image data is stored in 32-bit units, with the
269
+ * pixels ordered from left to right in the image being
270
+ * stored in order from the MSB to LSB within the word,
271
+ * for both big-endian and little-endian machines.
272
+ * This is the natural ordering for big-endian machines,
273
+ * as successive bytes are stored and fetched progressively
274
+ * to the right. However, for little-endians, when storing
275
+ * we re-order the bytes from this byte stream order, and
276
+ * reshuffle again for byte access on 32-bit entities.
277
+ * So if the bytes come in sequence from left to right, we
278
+ * store them on little-endians in byte order:
279
+ * 3 2 1 0 7 6 5 4 ...
280
+ * This MSB to LSB ordering allows left and right shift
281
+ * operations on 32 bit words to move the pixels properly.
282
+ *
283
+ * (4) For 24-bit color images, use 32 bpp data, leaving
284
+ * the fourth byte unused. Within each 4 byte pixel, the
285
+ * colors are ordered from MSB to LSB, as follows:
286
+ *
287
+ * | MSB | 2nd MSB | 3rd MSB | LSB |
288
+ * red green blue unused
289
+ * 0 1 2 3 (big-endian)
290
+ * 3 2 1 0 (little-endian)
291
+ *
292
+ * Because we use MSB to LSB ordering within the 32-bit word,
293
+ * the individual 8-bit samples can be accessed with
294
+ * GET_DATA_BYTE and SET_DATA_BYTE macros, using the
295
+ * (implicitly big-ending) ordering
296
+ * red: byte 0 (MSB)
297
+ * green: byte 1 (2nd MSB)
298
+ * blue: byte 2 (3rd MSB)
299
+ *
300
+ * This specific color assignment is made in this file,
301
+ * through the definitions of COLOR_RED, etc. Then the R, G
302
+ * and B sample values can be retrieved using
303
+ * redval = GET_DATA_BYTE(&pixel, COLOR_RED);
304
+ * greenval = GET_DATA_BYTE(&pixel, COLOR_GREEN);
305
+ * blueval = GET_DATA_BYTE(&pixel, COLOR_BLUE);
306
+ * and they can be set with
307
+ * SET_DATA_BYTE(&pixel, COLOR_RED, redval);
308
+ * SET_DATA_BYTE(&pixel, COLOR_GREEN, greenval);
309
+ * SET_DATA_BYTE(&pixel, COLOR_BLUE, blueval);
310
+ *
311
+ * For extra speed we extract the R, G and B colors directly
312
+ * by shifting and masking, explicitly using the values in
313
+ * L_RED_SHIFT, L_GREEN_SHIFT and L_BLUE_SHIFT:
314
+ * (pixel32 >> L_RED_SHIFT) & 0xff; (red)
315
+ * (pixel32 >> L_GREEN_SHIFT) & 0xff; (green)
316
+ * (pixel32 >> L_BLUE_SHIFT) & 0xff; (blue)
317
+ * All these operations work properly on both big- and little-endians.
318
+ *
319
+ * For a few situations, these color shift values are hard-coded.
320
+ * Changing the RGB color component ordering through the assignments
321
+ * in this file will cause functions marked with "***" to fail.
322
+ *
323
+ * (5) A reference count is held within each pix, giving the
324
+ * number of ptrs to the pix. When a pixClone() call
325
+ * is made, the ref count is increased by 1, and
326
+ * when a pixDestroy() call is made, the reference count
327
+ * of the pix is decremented. The pix is only destroyed
328
+ * when the reference count goes to zero.
329
+ *
330
+ * (6) The version numbers (below) are used in the serialization
331
+ * of these data structures. They are placed in the files,
332
+ * and rarely (if ever) change. Provision is currently made for
333
+ * backward compatibility in reading from boxaa version 2.
334
+ *
335
+ * (7) The serialization dependencies are as follows:
336
+ * pixaa : pixa : boxa
337
+ * boxaa : boxa
338
+ * So, for example, pixaa and boxaa can be changed without
339
+ * forcing a change in pixa or boxa. However, if pixa is
340
+ * changed, it forces a change in pixaa, and if boxa is
341
+ * changed, if forces a change in the other three.
342
+ * We define four version numbers:
343
+ * PIXAA_VERSION_NUMBER
344
+ * PIXA_VERSION_NUMBER
345
+ * BOXAA_VERSION_NUMBER
346
+ * BOXA_VERSION_NUMBER
347
+ *
348
+ *-------------------------------------------------------------------------*/
349
+
350
+
351
+
352
+ /*-------------------------------------------------------------------------*
353
+ * Array of pix *
354
+ *-------------------------------------------------------------------------*/
355
+
356
+ /* Serialization for primary data structures */
357
+ #define PIXAA_VERSION_NUMBER 2
358
+ #define PIXA_VERSION_NUMBER 2
359
+ #define BOXA_VERSION_NUMBER 2
360
+ #define BOXAA_VERSION_NUMBER 3
361
+
362
+
363
+ struct Pixa
364
+ {
365
+ l_int32 n; /* number of Pix in ptr array */
366
+ l_int32 nalloc; /* number of Pix ptrs allocated */
367
+ l_uint32 refcount; /* reference count (1 if no clones) */
368
+ struct Pix **pix; /* the array of ptrs to pix */
369
+ struct Boxa *boxa; /* array of boxes */
370
+ };
371
+ typedef struct Pixa PIXA;
372
+
373
+
374
+ struct Pixaa
375
+ {
376
+ l_int32 n; /* number of Pixa in ptr array */
377
+ l_int32 nalloc; /* number of Pixa ptrs allocated */
378
+ struct Pixa **pixa; /* array of ptrs to pixa */
379
+ struct Boxa *boxa; /* array of boxes */
380
+ };
381
+ typedef struct Pixaa PIXAA;
382
+
383
+
384
+ /*-------------------------------------------------------------------------*
385
+ * Basic rectangle and rectangle arrays *
386
+ *-------------------------------------------------------------------------*/
387
+ struct Box
388
+ {
389
+ l_int32 x;
390
+ l_int32 y;
391
+ l_int32 w;
392
+ l_int32 h;
393
+ l_uint32 refcount; /* reference count (1 if no clones) */
394
+
395
+ };
396
+ typedef struct Box BOX;
397
+
398
+ struct Boxa
399
+ {
400
+ l_int32 n; /* number of box in ptr array */
401
+ l_int32 nalloc; /* number of box ptrs allocated */
402
+ l_uint32 refcount; /* reference count (1 if no clones) */
403
+ struct Box **box; /* box ptr array */
404
+ };
405
+ typedef struct Boxa BOXA;
406
+
407
+ struct Boxaa
408
+ {
409
+ l_int32 n; /* number of boxa in ptr array */
410
+ l_int32 nalloc; /* number of boxa ptrs allocated */
411
+ struct Boxa **boxa; /* boxa ptr array */
412
+ };
413
+ typedef struct Boxaa BOXAA;
414
+
415
+
416
+ /*-------------------------------------------------------------------------*
417
+ * Array of points *
418
+ *-------------------------------------------------------------------------*/
419
+ #define PTA_VERSION_NUMBER 1
420
+
421
+ struct Pta
422
+ {
423
+ l_int32 n; /* actual number of pts */
424
+ l_int32 nalloc; /* size of allocated arrays */
425
+ l_int32 refcount; /* reference count (1 if no clones) */
426
+ l_float32 *x, *y; /* arrays of floats */
427
+ };
428
+ typedef struct Pta PTA;
429
+
430
+
431
+ /*-------------------------------------------------------------------------*
432
+ * Array of Pta *
433
+ *-------------------------------------------------------------------------*/
434
+ struct Ptaa
435
+ {
436
+ l_int32 n; /* number of pta in ptr array */
437
+ l_int32 nalloc; /* number of pta ptrs allocated */
438
+ struct Pta **pta; /* pta ptr array */
439
+ };
440
+ typedef struct Ptaa PTAA;
441
+
442
+
443
+ /*-------------------------------------------------------------------------*
444
+ * Pix accumulator container *
445
+ *-------------------------------------------------------------------------*/
446
+ struct Pixacc
447
+ {
448
+ l_int32 w; /* array width */
449
+ l_int32 h; /* array height */
450
+ l_int32 offset; /* used to allow negative */
451
+ /* intermediate results */
452
+ struct Pix *pix; /* the 32 bit accumulator pix */
453
+ };
454
+ typedef struct Pixacc PIXACC;
455
+
456
+
457
+ /*-------------------------------------------------------------------------*
458
+ * Pix tiling *
459
+ *-------------------------------------------------------------------------*/
460
+ struct PixTiling
461
+ {
462
+ struct Pix *pix; /* input pix (a clone) */
463
+ l_int32 nx; /* number of tiles horizontally */
464
+ l_int32 ny; /* number of tiles vertically */
465
+ l_int32 w; /* tile width */
466
+ l_int32 h; /* tile height */
467
+ l_int32 xoverlap; /* overlap on left and right */
468
+ l_int32 yoverlap; /* overlap on top and bottom */
469
+ l_int32 strip; /* strip for paint; default is TRUE */
470
+ };
471
+ typedef struct PixTiling PIXTILING;
472
+
473
+
474
+ /*-------------------------------------------------------------------------*
475
+ * FPix: pix with float array *
476
+ *-------------------------------------------------------------------------*/
477
+ #define FPIX_VERSION_NUMBER 1
478
+
479
+ struct FPix
480
+ {
481
+ l_int32 w; /* width in pixels */
482
+ l_int32 h; /* height in pixels */
483
+ l_int32 wpl; /* 32-bit words/line */
484
+ l_int32 refcount; /* reference count (1 if no clones) */
485
+ l_int32 xres; /* image res (ppi) in x direction */
486
+ /* (use 0 if unknown) */
487
+ l_int32 yres; /* image res (ppi) in y direction */
488
+ /* (use 0 if unknown) */
489
+ l_float32 *data; /* the float image data */
490
+ };
491
+ typedef struct FPix FPIX;
492
+
493
+
494
+ struct FPixa
495
+ {
496
+ l_int32 n; /* number of Pix in ptr array */
497
+ l_int32 nalloc; /* number of Pix ptrs allocated */
498
+ l_uint32 refcount; /* reference count (1 if no clones) */
499
+ struct FPix **fpix; /* the array of ptrs to fpix */
500
+ };
501
+ typedef struct FPixa FPIXA;
502
+
503
+
504
+ /*-------------------------------------------------------------------------*
505
+ * DPix: pix with double array *
506
+ *-------------------------------------------------------------------------*/
507
+ #define DPIX_VERSION_NUMBER 1
508
+
509
+ struct DPix
510
+ {
511
+ l_int32 w; /* width in pixels */
512
+ l_int32 h; /* height in pixels */
513
+ l_int32 wpl; /* 32-bit words/line */
514
+ l_int32 refcount; /* reference count (1 if no clones) */
515
+ l_int32 xres; /* image res (ppi) in x direction */
516
+ /* (use 0 if unknown) */
517
+ l_int32 yres; /* image res (ppi) in y direction */
518
+ /* (use 0 if unknown) */
519
+ l_float64 *data; /* the double image data */
520
+ };
521
+ typedef struct DPix DPIX;
522
+
523
+
524
+ /*-------------------------------------------------------------------------*
525
+ * PixComp: compressed pix *
526
+ *-------------------------------------------------------------------------*/
527
+ struct PixComp
528
+ {
529
+ l_int32 w; /* width in pixels */
530
+ l_int32 h; /* height in pixels */
531
+ l_int32 d; /* depth in bits */
532
+ l_int32 xres; /* image res (ppi) in x direction */
533
+ /* (use 0 if unknown) */
534
+ l_int32 yres; /* image res (ppi) in y direction */
535
+ /* (use 0 if unknown) */
536
+ l_int32 comptype; /* compressed format (IFF_TIFF_G4, */
537
+ /* IFF_PNG, IFF_JFIF_JPEG) */
538
+ char *text; /* text string associated with pix */
539
+ l_int32 cmapflag; /* flag (1 for cmap, 0 otherwise) */
540
+ l_uint8 *data; /* the compressed image data */
541
+ size_t size; /* size of the data array */
542
+ };
543
+ typedef struct PixComp PIXC;
544
+
545
+
546
+ /*-------------------------------------------------------------------------*
547
+ * PixaComp: array of compressed pix *
548
+ *-------------------------------------------------------------------------*/
549
+ #define PIXACOMP_VERSION_NUMBER 1
550
+
551
+ struct PixaComp
552
+ {
553
+ l_int32 n; /* number of PixComp in ptr array */
554
+ l_int32 nalloc; /* number of PixComp ptrs allocated */
555
+ struct PixComp **pixc; /* the array of ptrs to PixComp */
556
+ struct Boxa *boxa; /* array of boxes */
557
+ };
558
+ typedef struct PixaComp PIXAC;
559
+
560
+
561
+ /*-------------------------------------------------------------------------*
562
+ * Access and storage flags *
563
+ *-------------------------------------------------------------------------*/
564
+ /*
565
+ * For Pix, Box, Pta and Numa, there are 3 standard methods for handling
566
+ * the retrieval or insertion of a struct:
567
+ * (1) direct insertion (Don't do this if there is another handle
568
+ * somewhere to this same struct!)
569
+ * (2) copy (Always safe, sets up a refcount of 1 on the new object.
570
+ * Can be undesirable if very large, such as an image or
571
+ * an array of images.)
572
+ * (3) clone (Makes another handle to the same struct, and bumps the
573
+ * refcount up by 1. Safe to do unless you're changing
574
+ * data through one of the handles but don't want those
575
+ * changes to be seen by the other handle.)
576
+ *
577
+ * For Pixa and Boxa, which are structs that hold an array of clonable
578
+ * structs, there is an additional method:
579
+ * (4) copy-clone (Makes a new higher-level struct with a refcount
580
+ * of 1, but clones all the structs in the array.)
581
+ *
582
+ * Unlike the other structs, when retrieving a string from an Sarray,
583
+ * you are allowed to get a handle without a copy or clone (i.e., that
584
+ * you don't own!). You must not free or insert such a string!
585
+ * Specifically, for an Sarray, the copyflag for retrieval is either:
586
+ * TRUE (or 1 or L_COPY)
587
+ * or
588
+ * FALSE (or 0 or L_NOCOPY)
589
+ * For insertion, the copyflag is either:
590
+ * TRUE (or 1 or L_COPY)
591
+ * or
592
+ * FALSE (or 0 or L_INSERT)
593
+ * Note that L_COPY is always 1, and L_INSERT and L_NOCOPY are always 0.
594
+ */
595
+ enum {
596
+ L_INSERT = 0, /* stuff it in; no copy, clone or copy-clone */
597
+ L_COPY = 1, /* make/use a copy of the object */
598
+ L_CLONE = 2, /* make/use clone (ref count) of the object */
599
+ L_COPY_CLONE = 3 /* make a new object and fill with with clones */
600
+ /* of each object in the array(s) */
601
+ };
602
+ static const l_int32 L_NOCOPY = 0; /* copyflag value in sarrayGetString() */
603
+
604
+
605
+ /*--------------------------------------------------------------------------*
606
+ * Sort flags *
607
+ *--------------------------------------------------------------------------*/
608
+ enum {
609
+ L_SORT_INCREASING = 1, /* sort in increasing order */
610
+ L_SORT_DECREASING = 2 /* sort in decreasing order */
611
+ };
612
+
613
+ enum {
614
+ L_SORT_BY_X = 3, /* sort box or c.c. by horiz location */
615
+ L_SORT_BY_Y = 4, /* sort box or c.c. by vert location */
616
+ L_SORT_BY_WIDTH = 5, /* sort box or c.c. by width */
617
+ L_SORT_BY_HEIGHT = 6, /* sort box or c.c. by height */
618
+ L_SORT_BY_MIN_DIMENSION = 7, /* sort box or c.c. by min dimension */
619
+ L_SORT_BY_MAX_DIMENSION = 8, /* sort box or c.c. by max dimension */
620
+ L_SORT_BY_PERIMETER = 9, /* sort box or c.c. by perimeter */
621
+ L_SORT_BY_AREA = 10, /* sort box or c.c. by area */
622
+ L_SORT_BY_ASPECT_RATIO = 11 /* sort box or c.c. by width/height ratio */
623
+ };
624
+
625
+
626
+ /*-------------------------------------------------------------------------*
627
+ * Blend flags *
628
+ *-------------------------------------------------------------------------*/
629
+ enum {
630
+ L_BLEND_WITH_INVERSE = 1, /* add some of src inverse to itself */
631
+ L_BLEND_TO_WHITE = 2, /* shift src colors towards white */
632
+ L_BLEND_TO_BLACK = 3, /* shift src colors towards black */
633
+ L_BLEND_GRAY = 4, /* blend src directly with blender */
634
+ L_BLEND_GRAY_WITH_INVERSE = 5 /* add amount of src inverse to itself, */
635
+ /* based on blender pix value */
636
+ };
637
+
638
+ enum {
639
+ L_PAINT_LIGHT = 1, /* colorize non-black pixels */
640
+ L_PAINT_DARK = 2 /* colorize non-white pixels */
641
+ };
642
+
643
+
644
+ /*-------------------------------------------------------------------------*
645
+ * Graphics pixel setting *
646
+ *-------------------------------------------------------------------------*/
647
+ enum {
648
+ L_SET_PIXELS = 1, /* set all bits in each pixel to 1 */
649
+ L_CLEAR_PIXELS = 2, /* set all bits in each pixel to 0 */
650
+ L_FLIP_PIXELS = 3 /* flip all bits in each pixel */
651
+ };
652
+
653
+
654
+ /*-------------------------------------------------------------------------*
655
+ * Size filter flags *
656
+ *-------------------------------------------------------------------------*/
657
+ enum {
658
+ L_SELECT_WIDTH = 1, /* width must satisfy constraint */
659
+ L_SELECT_HEIGHT = 2, /* height must satisfy constraint */
660
+ L_SELECT_IF_EITHER = 3, /* either width or height can satisfy */
661
+ L_SELECT_IF_BOTH = 4 /* both width and height must satisfy */
662
+ };
663
+
664
+ enum {
665
+ L_SELECT_IF_LT = 1, /* save if value is less than threshold */
666
+ L_SELECT_IF_GT = 2, /* save if value is more than threshold */
667
+ L_SELECT_IF_LTE = 3, /* save if value is <= to the threshold */
668
+ L_SELECT_IF_GTE = 4 /* save if value is >= to the threshold */
669
+ };
670
+
671
+
672
+ /*-------------------------------------------------------------------------*
673
+ * Color component selection flags *
674
+ *-------------------------------------------------------------------------*/
675
+ enum {
676
+ L_SELECT_RED = 1, /* use red component */
677
+ L_SELECT_GREEN = 2, /* use green component */
678
+ L_SELECT_BLUE = 3, /* use blue component */
679
+ L_SELECT_MIN = 4, /* use min color component */
680
+ L_SELECT_MAX = 5 /* use max color component */
681
+ };
682
+
683
+
684
+ /*-------------------------------------------------------------------------*
685
+ * Rotate and shear flags *
686
+ *-------------------------------------------------------------------------*/
687
+ enum {
688
+ L_ROTATE_AREA_MAP = 1, /* use area map rotation, if possible */
689
+ L_ROTATE_SHEAR = 2, /* use shear rotation */
690
+ L_ROTATE_SAMPLING = 3 /* use sampling */
691
+ };
692
+
693
+ enum {
694
+ L_BRING_IN_WHITE = 1, /* bring in white pixels from the outside */
695
+ L_BRING_IN_BLACK = 2 /* bring in black pixels from the outside */
696
+ };
697
+
698
+ enum {
699
+ L_SHEAR_ABOUT_CORNER = 1, /* shear image about UL corner */
700
+ L_SHEAR_ABOUT_CENTER = 2 /* shear image about center */
701
+ };
702
+
703
+
704
+ /*-------------------------------------------------------------------------*
705
+ * Affine transform order flags *
706
+ *-------------------------------------------------------------------------*/
707
+ enum {
708
+ L_TR_SC_RO = 1, /* translate, scale, rotate */
709
+ L_SC_RO_TR = 2, /* scale, rotate, translate */
710
+ L_RO_TR_SC = 3, /* rotate, translate, scale */
711
+ L_TR_RO_SC = 4, /* translate, rotate, scale */
712
+ L_RO_SC_TR = 5, /* rotate, scale, translate */
713
+ L_SC_TR_RO = 6 /* scale, translate, rotate */
714
+ };
715
+
716
+
717
+ /*-------------------------------------------------------------------------*
718
+ * Grayscale filling flags *
719
+ *-------------------------------------------------------------------------*/
720
+ enum {
721
+ L_FILL_WHITE = 1, /* fill white pixels (e.g, in fg map) */
722
+ L_FILL_BLACK = 2 /* fill black pixels (e.g., in bg map) */
723
+ };
724
+
725
+
726
+ /*-------------------------------------------------------------------------*
727
+ * Flags for setting to white or black *
728
+ *-------------------------------------------------------------------------*/
729
+ enum {
730
+ L_SET_WHITE = 1, /* set pixels to white */
731
+ L_SET_BLACK = 2 /* set pixels to black */
732
+ };
733
+
734
+
735
+ /*-------------------------------------------------------------------------*
736
+ * Dither parameters *
737
+ * If within this grayscale distance from black or white, *
738
+ * do not propagate excess or deficit to neighboring pixels. *
739
+ *-------------------------------------------------------------------------*/
740
+ enum {
741
+ DEFAULT_CLIP_LOWER_1 = 10, /* dist to black with no prop; 1 bpp */
742
+ DEFAULT_CLIP_UPPER_1 = 10, /* dist to black with no prop; 1 bpp */
743
+ DEFAULT_CLIP_LOWER_2 = 5, /* dist to black with no prop; 2 bpp */
744
+ DEFAULT_CLIP_UPPER_2 = 5 /* dist to black with no prop; 2 bpp */
745
+ };
746
+
747
+
748
+ /*-------------------------------------------------------------------------*
749
+ * Distance flags *
750
+ *-------------------------------------------------------------------------*/
751
+ enum {
752
+ L_MANHATTAN_DISTANCE = 1, /* L1 distance (e.g., in color space) */
753
+ L_EUCLIDEAN_DISTANCE = 2 /* L2 distance */
754
+ };
755
+
756
+
757
+ /*-------------------------------------------------------------------------*
758
+ * Statistical measures *
759
+ *-------------------------------------------------------------------------*/
760
+ enum {
761
+ L_MEAN_ABSVAL = 1, /* average of abs values */
762
+ L_MEDIAN_VAL = 2, /* median value of set */
763
+ L_MODE_VAL = 3, /* mode value of set */
764
+ L_MODE_COUNT = 4, /* mode count of set */
765
+ L_ROOT_MEAN_SQUARE = 5, /* rms of values */
766
+ L_STANDARD_DEVIATION = 6, /* standard deviation from mean */
767
+ L_VARIANCE = 7 /* variance of values */
768
+ };
769
+
770
+
771
+ /*-------------------------------------------------------------------------*
772
+ * Set selection flags *
773
+ *-------------------------------------------------------------------------*/
774
+ enum {
775
+ L_CHOOSE_CONSECUTIVE = 1, /* select 'n' consecutive */
776
+ L_CHOOSE_SKIP_BY = 2 /* select at intervals of 'n' */
777
+ };
778
+
779
+
780
+ /*-------------------------------------------------------------------------*
781
+ * Text orientation flags *
782
+ *-------------------------------------------------------------------------*/
783
+ enum {
784
+ L_TEXT_ORIENT_UNKNOWN = 0, /* low confidence on text orientation */
785
+ L_TEXT_ORIENT_UP = 1, /* portrait, text rightside-up */
786
+ L_TEXT_ORIENT_LEFT = 2, /* landscape, text up to left */
787
+ L_TEXT_ORIENT_DOWN = 3, /* portrait, text upside-down */
788
+ L_TEXT_ORIENT_RIGHT = 4 /* landscape, text up to right */
789
+ };
790
+
791
+
792
+ /*-------------------------------------------------------------------------*
793
+ * Edge orientation flags *
794
+ *-------------------------------------------------------------------------*/
795
+ enum {
796
+ L_HORIZONTAL_EDGES = 0, /* filters for horizontal edges */
797
+ L_VERTICAL_EDGES = 1, /* filters for vertical edges */
798
+ L_ALL_EDGES = 2 /* filters for all edges */
799
+ };
800
+
801
+
802
+ /*-------------------------------------------------------------------------*
803
+ * Line orientation flags *
804
+ *-------------------------------------------------------------------------*/
805
+ enum {
806
+ L_HORIZONTAL_LINE = 0, /* horizontal line */
807
+ L_POS_SLOPE_LINE = 1, /* 45 degree line with positive slope */
808
+ L_VERTICAL_LINE = 2, /* vertical line */
809
+ L_NEG_SLOPE_LINE = 3, /* 45 degree line with negative slope */
810
+ L_OBLIQUE_LINE = 4 /* neither horizontal nor vertical */
811
+ };
812
+
813
+
814
+ /*-------------------------------------------------------------------------*
815
+ * Scan direction flags *
816
+ *-------------------------------------------------------------------------*/
817
+ enum {
818
+ L_FROM_LEFT = 0, /* scan from left */
819
+ L_FROM_RIGHT = 1, /* scan from right */
820
+ L_FROM_TOP = 2, /* scan from top */
821
+ L_FROM_BOTTOM = 3 /* scan from bottom */
822
+ };
823
+
824
+
825
+ /*-------------------------------------------------------------------------*
826
+ * Horizontal warp *
827
+ *-------------------------------------------------------------------------*/
828
+ enum {
829
+ L_WARP_TO_LEFT = 1, /* increasing stretch or contraction to left */
830
+ L_WARP_TO_RIGHT = 2 /* increasing stretch or contraction to right */
831
+ };
832
+
833
+ enum {
834
+ L_LINEAR_WARP = 1, /* stretch or contraction grows linearly */
835
+ L_QUADRATIC_WARP = 2 /* stretch or contraction grows quadratically */
836
+ };
837
+
838
+
839
+ /*-------------------------------------------------------------------------*
840
+ * Pixel selection for resampling *
841
+ *-------------------------------------------------------------------------*/
842
+ enum {
843
+ L_INTERPOLATED = 1, /* linear interpolation from src pixels */
844
+ L_SAMPLED = 2 /* nearest src pixel sampling only */
845
+ };
846
+
847
+
848
+ /*-------------------------------------------------------------------------*
849
+ * Thinning flags *
850
+ *-------------------------------------------------------------------------*/
851
+ enum {
852
+ L_THIN_FG = 1, /* thin foreground of 1 bpp image */
853
+ L_THIN_BG = 2 /* thin background of 1 bpp image */
854
+ };
855
+
856
+
857
+ /*-------------------------------------------------------------------------*
858
+ * Runlength flags *
859
+ *-------------------------------------------------------------------------*/
860
+ enum {
861
+ L_HORIZONTAL_RUNS = 0, /* determine runlengths of horizontal runs */
862
+ L_VERTICAL_RUNS = 1 /* determine runlengths of vertical runs */
863
+ };
864
+
865
+
866
+ /*-------------------------------------------------------------------------*
867
+ * Edge filter flags *
868
+ *-------------------------------------------------------------------------*/
869
+ enum {
870
+ L_SOBEL_EDGE = 1, /* Sobel edge filter */
871
+ L_TWO_SIDED_EDGE = 2 /* Two-sided edge filter */
872
+ };
873
+
874
+
875
+ /*-------------------------------------------------------------------------*
876
+ * Handling negative values in conversion to unsigned int *
877
+ *-------------------------------------------------------------------------*/
878
+ enum {
879
+ L_CLIP_TO_ZERO = 1, /* Clip negative values to 0 */
880
+ L_TAKE_ABSVAL = 2 /* Convert to positive using L_ABS() */
881
+ };
882
+
883
+
884
+ /*-------------------------------------------------------------------------*
885
+ * Subpixel color component ordering in LCD display *
886
+ *-------------------------------------------------------------------------*/
887
+ enum {
888
+ L_SUBPIXEL_ORDER_RGB = 1, /* sensor order left-to-right RGB */
889
+ L_SUBPIXEL_ORDER_BGR = 2, /* sensor order left-to-right BGR */
890
+ L_SUBPIXEL_ORDER_VRGB = 3, /* sensor order top-to-bottom RGB */
891
+ L_SUBPIXEL_ORDER_VBGR = 4 /* sensor order top-to-bottom BGR */
892
+ };
893
+
894
+
895
+ /*-------------------------------------------------------------------------*
896
+ * Relative to zero flags *
897
+ *-------------------------------------------------------------------------*/
898
+ enum {
899
+ L_LESS_THAN_ZERO = 1, /* Choose values less than zero */
900
+ L_EQUAL_TO_ZERO = 2, /* Choose values equal to zero */
901
+ L_GREATER_THAN_ZERO = 3 /* Choose values greater than zero */
902
+ };
903
+
904
+
905
+ /*-------------------------------------------------------------------------*
906
+ * HSV histogram flags *
907
+ *-------------------------------------------------------------------------*/
908
+ enum {
909
+ L_HS_HISTO = 1, /* Use hue-saturation histogram */
910
+ L_HV_HISTO = 2, /* Use hue-value histogram */
911
+ L_SV_HISTO = 3 /* Use saturation-value histogram */
912
+ };
913
+
914
+
915
+ /*-------------------------------------------------------------------------*
916
+ * Region flags (inclusion, exclusion) *
917
+ *-------------------------------------------------------------------------*/
918
+ enum {
919
+ L_INCLUDE_REGION = 1, /* Use hue-saturation histogram */
920
+ L_EXCLUDE_REGION = 2 /* Use hue-value histogram */
921
+ };
922
+
923
+
924
+ /*-------------------------------------------------------------------------*
925
+ * Flags for adding text to a pix *
926
+ *-------------------------------------------------------------------------*/
927
+ enum {
928
+ L_ADD_ABOVE = 1, /* Add text above the image */
929
+ L_ADD_AT_TOP = 2, /* Add text over the top of the image */
930
+ L_ADD_AT_BOTTOM = 3, /* Add text over the bottom of the image */
931
+ L_ADD_BELOW = 4 /* Add text below the image */
932
+ };
933
+
934
+
935
+ /*-------------------------------------------------------------------------*
936
+ * Flags for selecting display program *
937
+ *-------------------------------------------------------------------------*/
938
+ enum {
939
+ L_DISPLAY_WITH_XV = 1, /* Use xv with pixDisplay() */
940
+ L_DISPLAY_WITH_XLI = 2, /* Use xli with pixDisplay() */
941
+ L_DISPLAY_WITH_XZGV = 3, /* Use xzgv with pixDisplay() */
942
+ L_DISPLAY_WITH_IV = 4 /* Use irfvanview with pixDisplay() */
943
+ };
944
+
945
+ #endif /* LEPTONICA_PIX_H */