Debian Codegraph @

src/matcher/bitmaps.h

raw
1 /* Plasma OCR - an OCR engine
2 *
3 * bitmaps.h - some routines that work with bitmaps
4 *
5 * Copyright (C) 2006 Ilya Mezhirov
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22
23 /* Since Plasma is going into touch with many other projects,
24 * I've decided not to write nor use any class for bitmaps.
25 * It's always just (unsigned char **pixels, int w, int h).
26 */
27
28 #ifndef PLASMA_OCR_BITMAP_H
29 #define PLASMA_OCR_BITMAP_H
30
31
32 #include "common.h"
33
34 FUNCTIONS_BEGIN
35
36 /* Just allocate a w * h array. */
37 unsigned char **allocate_bitmap(int w, int h);
38 void free_bitmap(unsigned char **);
39 void assign_bitmap(unsigned char **dst, unsigned char **src, int w, int h);
40 unsigned char **copy_bitmap(unsigned char **, int w, int h);
41
42
43 /* Allocate a w * h bitmap with margins of 1 pixels at each side.
44 * Indices into such a bitmap range from -1 to w or h.
45 * Free the allocated bitmap with free_bitmap_with_margins().
46 */
47 unsigned char **allocate_bitmap_with_margins(int w, int h);
48 void free_bitmap_with_margins(unsigned char **);
49
50 /* Allocate bitmap with margins and clear those margins. */
51 unsigned char **allocate_bitmap_with_white_margins(int w, int h);
52
53
54 void print_bitmap(unsigned char **, int w, int h);
55
56
57 /* Allocate a w * h bitmap with margins of 1 pixels at each side.
58 * Copy `pixels' there and clear the margins.
59 */
60 unsigned char **provide_margins(unsigned char **, int w, int h, int make_it_0_or_1);
61
62
63 void make_bitmap_0_or_1(unsigned char **, int w, int h);
64
65
66 void invert_bitmap(unsigned char **, int w, int h, int first_make_it_0_or_1);
67
68 void clear_bitmap(unsigned char **pixels, int w, int h);
69
70
71 /* Clear pixels that have exactly 1 of 4 (or 8) neighbors.
72 * (Well, I have in mind some usage for this one).
73 *
74 * `pixels' must have margins.
75 *
76 * `result' cannot coincide with `pixels'.
77 */
78 void strip_endpoints_4(unsigned char **result, unsigned char **pixels, int w, int h);
79 void strip_endpoints_8(unsigned char **result, unsigned char **pixels, int w, int h);
80
81 FUNCTIONS_END
82
83 #endif