This file is indexed.

/usr/include/libhocr/ho_bitmap.h is in libhocr-dev 0.10.17-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
/***************************************************************************
 *            ho_bitmap.h
 *
 *  Fri Aug 12 20:13:33 2005
 *  Copyright  2005-2007  Yaacov Zamir
 *  <kzamir@walla.co.il>
 ****************************************************************************/

/*  
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/** @file ho_bitmap.h
    @brief libhocr C language header.
    
    libhocr - LIBrary for Hebrew Optical Character Recognition 
*/

#ifndef HO_BITMAP_H
#define HO_BITMAP_H 1

/* hocr bitmap set/get macros */
#define ho_bitmap_get(m,x,y) (((((m)->data[(x) / 8 + (y) * (m)->rowstride]) & (0x80 >> ((x) % 8))) > 0)?1:0)
#define ho_bitmap_set(m,x,y) (((m)->data[(x) / 8 + (y) * (m)->rowstride]) |= (0x80 >> ((x) % 8)))
#define ho_bitmap_unset(m,x,y) (((m)->data[(x) / 8 + (y) * (m)->rowstride]) &= ~(0x80 >> ((x) % 8)))

#define ho_bitmap_get_x(m) ((m)->x)
#define ho_bitmap_get_y(m) ((m)->y)
#define ho_bitmap_set_x(m,new_x) ((m)->x=(new_x))
#define ho_bitmap_set_y(m,new_y) ((m)->y=(new_y))
#define ho_bitmap_get_width(m) ((m)->width)
#define ho_bitmap_get_height(m) ((m)->height)

/** @struct ho_bitmap
  @brief libhocr bitmap struct
*/
typedef struct
{
  unsigned char type;
  int font_height;
  int font_width;

  int font_spacing;
  int line_spacing;
  int avg_line_fill;
  int com_line_fill;

  unsigned char nikud;

  int x;
  int y;
  int height;
  int width;
  int rowstride;
  unsigned char *data;
} ho_bitmap;

/**
 new ho_bitamp
 
 @param height hight of pixbuf in pixels
 @param width width of pixbuf in pixels
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_new (const int width, const int height);

/**
 free an ho_bitmap
 
 @param m pointer to an ho_bitmap
 @return FALSE
 */
int ho_bitmap_free (ho_bitmap * m);

/**
 copy a bitmap
 
 @param m the bitmap to copy
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_clone (const ho_bitmap * m);

/**
 copy a window from a bitmap
 
 @param m the bitmap to copy
 @param x x-start of window
 @param y y-start of window
 @param width width of window
 @param height height of window
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_clone_window (const ho_bitmap * m, const int x,
  const int y, const int width, const int height);

/**
 do bitwise and of two bitmaps
 
 @param m_left the left hand bitmap
 @param m_right the right hand bitmap
 @return FALSE
 */
int ho_bitmap_and (ho_bitmap * m_left, const ho_bitmap * m_right);

/**
 do bitwise or of two bitmaps
 
 @param m_left the left hand bitmap
 @param m_right the right hand bitmap
 @return FALSE
 */
int ho_bitmap_or (ho_bitmap * m_left, const ho_bitmap * m_right);

/**
 do bitwise xor of two bitmaps
 
 @param m_left the left hand bitmap
 @param m_right the right hand bitmap
 @return FALSE
 */
int ho_bitmap_xor (ho_bitmap * m_left, const ho_bitmap * m_right);

/**
 do bitwise and not of two bitmaps
 
 @param m_left the left hand bitmap
 @param m_right the right hand bitmap
 @return FALSE
 */
int ho_bitmap_andnot (ho_bitmap * m_left, const ho_bitmap * m_right);

/**
 do bitwise copy of two bitmaps
 
 @param m_left the left hand bitmap
 @param m_right the right hand bitmap
 @return FALSE
 */
int ho_bitmap_copy (ho_bitmap * m_left, const ho_bitmap * m_right);

/**
 do bitwise not of a bitmap
 
 @param m the left hand bitmap
 @return a newly allocated bitmap 
 */
ho_bitmap *ho_bitmap_not (const ho_bitmap * m);

/**
 dilation of a a bitmap with 3x3 box
 
 @param m the bitmap to dilate 
 @param n dilation constant
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_dilation_n (const ho_bitmap * m, const unsigned char n);

/**
 erosion of a a bitmap with 3x3 box
 
 @param m the bitmap to erode 
 @param n erosion constant
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_erosion_n (const ho_bitmap * m, const unsigned char n);

/**
 take only top height black pixels of bitmap
 
 @param m the bitmap to erode 
 @param height the height to take
 @param top space above black pixel included in new object
 @param bottom space below black pixel included in new object
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_set_height (const ho_bitmap * m, const int height,
  const int top, const int bottom);

/**
 take only bottom height black pixels of bitmap
 
 @param m the bitmap to erode 
 @param height the height to take
 @param top space above black pixel included in new object
 @param bottom space below black pixel included in new object
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_set_height_from_bottom (const ho_bitmap * m,
  const int height, const int top, const int bottom);

/**
 dilation of a a bitmap with 3x3 box
 
 @param m the bitmap to dilate 
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_dilation (const ho_bitmap * m);

/**
 erosion of a a bitmap with 3x3 box
 
 @param m the bitmap to erode
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_erosion (const ho_bitmap * m);

/**
 opening of a a bitmap with 3x3 box
 
 @param m the bitmap to open 
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_opening (const ho_bitmap * m);

/**
 closing of a a bitmap with 3x3 box
 
 @param m the bitmap to close 
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_closing (const ho_bitmap * m);

/**
 horizontaly link black dots in a bitmap
 
 @param m the bitmap to horizontaly link
 @param size maximum distance
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_hlink (const ho_bitmap * m, const int size);

/**
 horizontaly erode black dots in a bitmap
 
 @param m the bitmap to horizontaly link
 @param size maximum distance
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_herode (const ho_bitmap * m, const int size);

/**
 verticaly link black dots in a bitmap
 
 @param m the bitmap to verticaly link
 @param size maximum distance
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_vlink (const ho_bitmap * m, const int size);

/**
 copy edges in bitmap
 
 @param m pointer to an ho_bitmap
 @param n width of egde
 @return a newly allocated bitmap
 */
ho_bitmap *ho_bitmap_edge (const ho_bitmap * m, const int n);

/**
 return the ratio fill/volume value of a rectangle in the bitmap
 
 @param m pointer to an ho_bitmap
 @param x x of rectangel
 @param y y of rectangel
 @param width width of rectangel
 @param height height of rectangel
 @return the ratio value
 */
double
ho_bitmap_get_fill (const ho_bitmap * m, const int x, const int y,
  const int width, const int height);

/**
 horizontaly link short objects in a bitmap
 
 @param m the bitmap to horizontaly link
 @param size maximum distance
 @param max_height maximum hight of objects to link
 @return newly allocated ho_bitmap
 */
ho_bitmap *ho_bitmap_filter_hlink (ho_bitmap * m, int size, int max_height);

/**
 copy objects from bitmap to bitmap by size
 
 @param m pointer to an ho_bitmap
 @param min_height only objects with this minimal height are copied
 @param max_height only objects with this maximal height are copied
 @param min_width only objects with this minimal width are copied
 @param max_width only objects with this maximal width are copied
 @return a newly allocated bitmap
 */
ho_bitmap *ho_bitmap_filter_by_size (const ho_bitmap * m,
  int min_height, int max_height, int min_width, int max_width);

/**
 copy boxed objects from bitmap
 
 @param m pointer to an ho_bitmap
 @param leeway_down space below object to be included in box
 @param leeway_up space above object to be included in box
 @return a newly allocated bitmap
 */
ho_bitmap *ho_bitmap_filter_boxes (const ho_bitmap * m, const int leeway_down,
  const int leeway_up);

/**
 copy filled objects from bitmap
 
 @param m pointer to an ho_bitmap
 @return a newly allocated bitmap
 */
ho_bitmap *ho_bitmap_filter_fill (const ho_bitmap * m);

/**
 take height top pixels from objects in bitmap
 
 @param m pointer to an ho_bitmap
 @param height of new objects
 @param top space above black pixel included in new object
 @param bottom space below black pixel included in new object
 @return a newly allocated bitmap
 */
ho_bitmap *ho_bitmap_filter_set_height (const ho_bitmap * m, const int height,
  const int top, const int bottom);

/**
 take height bottom pixels from objects in bitmap
 
 @param m pointer to an ho_bitmap
 @param height of new objects
 @param top space above black pixel included in new object
 @param bottom space below black pixel included in new object
 @return a newly allocated bitmap
 */
ho_bitmap *ho_bitmap_filter_set_height_from_bottom (const ho_bitmap * m,
  const int height, const int top, const int bottom);

/**
 take extend objects lateraly
 
 @param m pointer to an ho_bitmap
 @param ext_width width of lateral extention
 @return a newly allocated bitmap
 */
ho_bitmap *ho_bitmap_filter_obj_extend_lateraly (const ho_bitmap * m,
  const int ext_width);

/**
 remove halftone dots from bitmap
 
 @param m pointer to an ho_bitmap
 @param erosion_n the erosion operator factor
 @param dilation_n the dilation operator factor
 @return a newly allocated bitmap
 */
ho_bitmap *ho_bitmap_filter_remove_dots (const ho_bitmap * m,
  const unsigned char erosion_n, const unsigned char dilation_n);

/**
 count the number of objects in a bitmap
 
 @param m pointer to an ho_bitmap
 @return the number of objects in a bitmap
 */
int ho_bitmap_filter_count_objects (const ho_bitmap * m);

/**
 draw a black box on bitmap
 
 @param m the bitmap to draw on
 @param x x-start of box
 @param y y-start of box
 @param width width of box
 @param height height of box
 @return FALSE
 */
int
ho_bitmap_draw_box (ho_bitmap * m, const int x, const int y,
  const int width, const int height);

/**
 draw a black empty box on bitmap
 
 @param m the bitmap to draw on
 @param x x-start of box
 @param y y-start of box
 @param width width of box
 @param height height of box
 @return FALSE
 */
int
ho_bitmap_draw_box_empty (ho_bitmap * m, const int x, const int y,
  const int width, const int height);

/**
 draw vertical line on bitmap
 
 @param m the bitmap to draw on
 @param x x-start of line
 @param y y-start of line
 @param height height of line
 @return FALSE
 */
int
ho_bitmap_draw_vline (ho_bitmap * m, const int x, const int y,
  const int height);

/**
 delete vertical line on bitmap
 
 @param m the bitmap to draw on
 @param x x-start of line
 @param y y-start of line
 @param height height of line
 @return FALSE
 */
int
ho_bitmap_delete_vline (ho_bitmap * m, const int x, const int y,
  const int height);

/**
 draw horizontal line on bitmap
 
 @param m the bitmap to draw on
 @param x x-start of line
 @param y y-start of line
 @param width height of line
 @return FALSE
 */
int
ho_bitmap_draw_hline (ho_bitmap * m, const int x, const int y, const int width);

/**
 delete horizontal line on bitmap
 
 @param m the bitmap to draw on
 @param x x-start of line
 @param y y-start of line
 @param width height of line
 @return FALSE
 */
int
ho_bitmap_delete_hline (ho_bitmap * m, const int x, const int y,
  const int width);

/**
 rotate a bitmap
 
 @param m the bitmap to rotate
 @param angle the angle in deg.
 @return newly allocated ho_bitmap
 */
ho_bitmap *
ho_bitmap_rotate (const ho_bitmap * m, const double angle);

/**
 writes ho_bitmap to pnm file
 
 @param m ho_bitmap 1 bpp
 @param filename save as file name 
 @return FALSE
 */
int ho_bitmap_pnm_save (const ho_bitmap * m, const char *filename);

/**
 writes ho_bitmap to tiff file
 
 @param m ho_bitmap 1 bpp
 @param filename save as file name 
 @return FALSE
 */
int ho_bitmap_tiff_save (const ho_bitmap * m, const char *filename);

#endif /* HO_BITMAP_H */