comparison mupdf-source/thirdparty/leptonica/src/jbclass.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
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_JBCLASS_H
28 #define LEPTONICA_JBCLASS_H
29
30 /*!
31 * \file jbclass.h
32 *
33 * JbClasser
34 * JbData
35 */
36
37
38 /*!
39 * <pre>
40 * The JbClasser struct holds all the data accumulated during the
41 * classification process that can be used for a compressed
42 * jbig2-type representation of a set of images. This is created
43 * in an initialization process and added to as the selected components
44 * on each successive page are analyzed.
45 * </pre>
46 */
47 struct JbClasser
48 {
49 struct Sarray *safiles; /*!< input page image file names */
50 l_int32 method; /*!< JB_RANKHAUS, JB_CORRELATION */
51 l_int32 components; /*!< JB_CONN_COMPS, JB_CHARACTERS or */
52 /*!< JB_WORDS */
53 l_int32 maxwidth; /*!< max component width allowed */
54 l_int32 maxheight; /*!< max component height allowed */
55 l_int32 npages; /*!< number of pages already processed */
56 l_int32 baseindex; /*!< number components already processed */
57 /*!< on fully processed pages */
58 struct Numa *nacomps; /*!< number of components on each page */
59 l_int32 sizehaus; /*!< size of square struct elem for haus */
60 l_float32 rankhaus; /*!< rank val of haus match, each way */
61 l_float32 thresh; /*!< thresh value for correlation score */
62 l_float32 weightfactor; /*!< corrects thresh value for heaver */
63 /*!< components; use 0 for no correction */
64 struct Numa *naarea; /*!< w * h of each template, without */
65 /*!< extra border pixels */
66 l_int32 w; /*!< max width of original src images */
67 l_int32 h; /*!< max height of original src images */
68 l_int32 nclass; /*!< current number of classes */
69 l_int32 keep_pixaa; /*!< If zero, pixaa isn't filled */
70 struct Pixaa *pixaa; /*!< instances for each class; unbordered */
71 struct Pixa *pixat; /*!< templates for each class; bordered */
72 /*!< and not dilated */
73 struct Pixa *pixatd; /*!< templates for each class; bordered */
74 /*!< and dilated */
75 struct L_DnaHash *dahash; /*!< Hash table to find templates by size */
76 struct Numa *nafgt; /*!< fg areas of undilated templates; */
77 /*!< only used for rank < 1.0 */
78 struct Pta *ptac; /*!< centroids of all bordered cc */
79 struct Pta *ptact; /*!< centroids of all bordered template cc */
80 struct Numa *naclass; /*!< array of class ids for each component */
81 struct Numa *napage; /*!< array of page nums for each component */
82 struct Pta *ptaul; /*!< array of UL corners at which the */
83 /*!< template is to be placed for each */
84 /*!< component */
85 struct Pta *ptall; /*!< similar to ptaul, but for LL corners */
86 };
87 typedef struct JbClasser JBCLASSER;
88
89
90 /*!
91 * <pre>
92 * The JbData struct holds all the data required for
93 * the compressed jbig-type representation of a set of images.
94 * The data can be written to file, read back, and used
95 * to regenerate an approximate version of the original,
96 * which differs in two ways from the original:
97 * (1) It uses a template image for each c.c. instead of the
98 * original instance, for each occurrence on each page.
99 * (2) It discards components with either a height or width larger
100 * than the maximuma, given here by the lattice dimensions
101 * used for storing the templates.
102 * </pre>
103 */
104 struct JbData
105 {
106 struct Pix *pix; /*!< template composite for all classes */
107 l_int32 npages; /*!< number of pages */
108 l_int32 w; /*!< max width of original page images */
109 l_int32 h; /*!< max height of original page images */
110 l_int32 nclass; /*!< number of classes */
111 l_int32 latticew; /*!< lattice width for template composite */
112 l_int32 latticeh; /*!< lattice height for template composite */
113 struct Numa *naclass; /*!< array of class ids for each component */
114 struct Numa *napage; /*!< array of page nums for each component */
115 struct Pta *ptaul; /*!< array of UL corners at which the */
116 /*!< template is to be placed for each */
117 /*!< component */
118 };
119 typedef struct JbData JBDATA;
120
121
122 /*! JB Classifier */
123 enum {
124 JB_RANKHAUS = 0,
125 JB_CORRELATION = 1
126 };
127
128 /*! For jbGetComponents(): type of component to extract from images */
129 /*! JB Component */
130 enum {
131 JB_CONN_COMPS = 0,
132 JB_CHARACTERS = 1,
133 JB_WORDS = 2
134 };
135
136 /*! These parameters are used for naming the two files
137 * in which the jbig2-like compressed data is stored. */
138 #define JB_TEMPLATE_EXT ".templates.png"
139 #define JB_DATA_EXT ".data"
140
141
142 #endif /* LEPTONICA_JBCLASS_H */