Skip to content

Commit f1edbd8

Browse files
zvezdochiotzdenop
authored andcommitted
neat symbolic threshold 0.92
1 parent 07151c0 commit f1edbd8

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ See the `jbig2enc.h` header for the high level API, or the `jbig2` program for a
2525
example of usage:
2626

2727
```
28-
$ jbig2 -s -p -v *.jpg && python3 jbig2topdf.py output >out.pdf
28+
$ jbig2 -s -a -p -v *.jpg && python3 jbig2topdf.py output >out.pdf
2929
```
3030

3131
or with standalone mode:
3232

3333
```
34-
$ jbig2 -p -v images/feyn.tif > feyn.jbig2 && python3 jbig2topdf.py -s feyn.jbig2 > feyn.pdf
34+
$ jbig2 -a -p -v images/feyn.tif > feyn.jbig2 && python3 jbig2topdf.py -s feyn.jbig2 > feyn.pdf
3535
```
3636

3737
to encode jbig2 files for pdf creation.

src/jbig2.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ usage(const char *argv0) {
4949
fprintf(stderr, " -d --duplicate-line-removal: use TPGD in generic region coder\n");
5050
fprintf(stderr, " -p --pdf: produce PDF ready data\n");
5151
fprintf(stderr, " -s --symbol-mode: use text region, not generic coder\n");
52-
fprintf(stderr, " -t <threshold>: set classification threshold for symbol coder (def: 0.85)\n");
52+
fprintf(stderr, " -t <threshold>: set classification threshold for symbol coder (def: 0.92)\n");
5353
fprintf(stderr, " -T <bw threshold>: set 1 bpp threshold (def: 188)\n");
5454
fprintf(stderr, " -r --refine: use refinement (requires -s: lossless)\n");
5555
fprintf(stderr, " -O <outfile>: dump thresholded image as PNG\n");
@@ -202,7 +202,7 @@ int
202202
main(int argc, char **argv) {
203203
bool duplicate_line_removal = false;
204204
bool pdfmode = false;
205-
float threshold = 0.85;
205+
float threshold = 0.92;
206206
int bw_threshold = 188;
207207
bool symbol_mode = false;
208208
bool refine = false;
@@ -308,9 +308,9 @@ main(int argc, char **argv) {
308308
return 1;
309309
}
310310

311-
if (threshold > 0.9 || threshold < 0.4) {
311+
if (threshold > 0.97 || threshold < 0.4) {
312312
fprintf(stderr, "Invalid value for threshold\n");
313-
fprintf(stderr, "(must be between 0.4 and 0.9)\n");
313+
fprintf(stderr, "(must be between 0.4 and 0.97)\n");
314314
return 10;
315315
}
316316
i++;

src/jbig2comparator.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ jbig2enc_are_equivalent(PIX *const first_template, PIX *const second_template) {
200200
horizontal_sum += horizontal_parsed_pix_counts[i+x][j+y];
201201
}
202202
}
203-
if (horizontal_sum > hline_thresh) {
203+
if (horizontal_sum >= hline_thresh) {
204204
return 0;
205205
}
206206
}
@@ -215,7 +215,7 @@ jbig2enc_are_equivalent(PIX *const first_template, PIX *const second_template) {
215215
vertical_sum += vertical_parsed_pix_counts[i+x][j+y];
216216
}
217217
}
218-
if (vertical_sum > vline_thresh) {
218+
if (vertical_sum >= vline_thresh) {
219219
return 0;
220220
}
221221
}
@@ -236,7 +236,7 @@ jbig2enc_are_equivalent(PIX *const first_template, PIX *const second_template) {
236236
}
237237
}
238238
}
239-
if ((left_cross > hline_thresh) || (right_cross > hline_thresh)) {
239+
if ((left_cross >= hline_thresh) || (right_cross >= hline_thresh)) {
240240
return 0;
241241
}
242242
}
@@ -253,7 +253,7 @@ jbig2enc_are_equivalent(PIX *const first_template, PIX *const second_template) {
253253
sum += parsed_pix_counts[i+x][j+y];
254254
}
255255
}
256-
if (sum > point_thresh) {
256+
if (sum >= point_thresh) {
257257
return 0;
258258
}
259259
}

0 commit comments

Comments
 (0)