forked from dfd-tud/deda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeda_clean_document.py
executable file
·50 lines (34 loc) · 1.33 KB
/
deda_clean_document.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Remove Yellow Dots From White Areas of Scanned Pages
Copyright 2018 Timo Richter
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.
'''
import cv2, argparse
from libdeda.extract_yd import ImgProcessingMixin
class Cleaner(ImgProcessingMixin):
_verbosity = 0
def __call__(self,output):
im = cv2.imread(self.path)
_, mask = self.processImage(im,workAtDpi=None,halftonesBlur=10,
ydColourRange=((16,1,214),(42,120,255)),
paperColourThreshold=225)#233
im[mask==255] = 255
cv2.imwrite(output,im)
class Main(object):
def argparser(self):
parser = argparse.ArgumentParser(description=
'Remove Yellow Dots From White Areas of Scanned Pages')
parser.add_argument("input", type=str, help='Path to Input File')
parser.add_argument("output", type=str, help='Path to Output File')
self.args = parser.parse_args()
def __init__(self):
self.argparser()
def __call__(self):
Cleaner(self.args.input)(self.args.output)
if __name__ == "__main__":
Main()()