This repository has been archived by the owner on May 25, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
sh_pp.h
77 lines (61 loc) · 1.76 KB
/
sh_pp.h
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
#ifndef SH_PP_H
#define SH_PP_H
#include "prefix.h"
#include "sh_hp.h"
#include "sh_oh.h"
#include "sh_gy.h"
#include "sh_th.h"
#include "sh_cs.h"
#include "sh_rl.h"
#include "sh_dn.h"
#include "sh_zm.h"
#include "sh_dk.h"
#include "sh_tn.h"
#include "sh_ed.h"
#include "sh_sc.h"
#include "sh_fx.h"
// image pre-processing
inline image_type sh_pp_preprocess(image_type const& old_img, bool is_online, pimages_info_row_type* ppir = NULL)
{
// copy
image_type img(old_img);
// image binarization
if (is_online)
{
img = sh_th_global_basic_threshold(img);
img = sh_oh_trim(img);
}
else img = sh_th_partial_otsu_threshold(img);
// adjust image size for better processing
//img = sh_dn_discrete_denoising(img);
//img = sh_dn_discrete_denoising(img);
#ifdef USING_THINNING
// thinning image
img = sh_tn_thinning(img); // need improve
#endif
// split image
pimages_info_row_type pir = sh_rl_labeling_split_to_row(img, !is_online);
// deskew iamges
sh_oh_deskew_from_pimgs_info_row(pir);
// fixes images
sh_oh_fixes_from_pimgs_info_row(pir); // need improve
// trim margin
sh_oh_trim_from_pimgs_info_row(pir);
// fill margin for 1
sh_oh_fill_margin_for_1_from_pimgs_info_row(pir, IMAGE_W, IMAGE_H);
// normalize images
if (is_online) sh_oh_normalize_from_pimgs_info_row(pir, IMAGE_W, IMAGE_H); // need improve
else sh_oh_normalize2_from_pimgs_info_row(pir, IMAGE_W, IMAGE_H);
// fixes images
sh_oh_fixes_from_pimgs_info_row(pir); // need improve
#ifdef USING_THINNING
// images thinning
sh_oh_thinning_from_pimgs_info_row(pir);
#endif
// merge images
img = sh_oh_merge_from_pimgs_info_row(pir);
// return images info
if (ppir) *ppir = pir;
return img;
}
#endif // SH_PP_H