despeck 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/README.adoc +128 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/despeck.gemspec +28 -0
- data/lib/despeck.rb +5 -0
- data/lib/despeck/version.rb +3 -0
- data/samples/red-circle/10-06.pdf +0 -0
- data/samples/red-circle/10-08.pdf +0 -0
- data/samples/red-circle/10-09.pdf +0 -0
- data/samples/red-circle/10-11.pdf +0 -0
- data/samples/red-circle/a-despecked.jpg +0 -0
- data/samples/red-circle/a.jpg +0 -0
- data/samples/red-circle/b.jpg +0 -0
- data/samples/red-circle/c.jpg +0 -0
- data/samples/red-circle/despecked-portion-parameters.png +0 -0
- data/samples/red-circle/despecked-portion.png +0 -0
- data/samples/red-circle/despecked-watermark-parameters.png +0 -0
- data/samples/red-circle/despecked-watermark.png +0 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 20d7af52df2f57a1c99cd47b9d63dcd28fb34280
|
4
|
+
data.tar.gz: 50b513bab961b88f9c7c7396e881c7cab07eeb67
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b88335d7ff52faacb2d14e7745e01e1e117e6056c4905891e8448ea53d3af40d5056786351d981cd882e7371b8f0a9a7ee04acb0a6b2f980ccdc8cd963cc21f3
|
7
|
+
data.tar.gz: 5f84d9d3e8429dc8e3462f404a6719b17e8a56a54c9eafb3291cc21e8776e4f2e8ed248d1bf89a74afa7f0b20a6d25b045c8a496c79bf10e2de1f4bf5fa598aa
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at ronald.tse@ribose.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/README.adoc
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
= despeck: remove unwanted stamps or watermarks from scanned images
|
2
|
+
|
3
|
+
`despeck` is a Ruby gem that helps you remove unwated stamps or watermarks from
|
4
|
+
scanned images/PDFs, primarily prior to OCR.
|
5
|
+
|
6
|
+
Its image processing operations are based on libvips via the
|
7
|
+
https://github.com/jcupitt/ruby-vips[ruby-vips] Ruby-bindings.
|
8
|
+
|
9
|
+
It can be used to:
|
10
|
+
|
11
|
+
* detect uniform watermarks from a series of images,
|
12
|
+
* output a watermark pattern file (image, mask) that describes a watermark pattern, and
|
13
|
+
* remove a specified watermark pattern from input images regardless of the
|
14
|
+
location of the watermark on these images.
|
15
|
+
|
16
|
+
Assumptions on input:
|
17
|
+
|
18
|
+
* The input may be a single image, or a PDF of multiple pages of images
|
19
|
+
* In the case of multiple pages, not all pages may have the watermark
|
20
|
+
* The input images are assumed to be purely monochrome text-based.
|
21
|
+
* The watermarks are colored and are located in a similar location within all
|
22
|
+
the pages. For example, if the watermark is a GREEN SQUARE PATTERN, for all
|
23
|
+
the pages that contain this mark, despeck will attempt to detect this pattern
|
24
|
+
and remove them
|
25
|
+
|
26
|
+
== Quick start
|
27
|
+
|
28
|
+
[source,sh]
|
29
|
+
----
|
30
|
+
gem install despeck
|
31
|
+
----
|
32
|
+
|
33
|
+
== Functionality
|
34
|
+
|
35
|
+
despect has three functions:
|
36
|
+
|
37
|
+
. recognize a common watermark from a set of input images. All of the input
|
38
|
+
images for detection should contain at least one of this mark.
|
39
|
+
. output a file that specifies a particular watermark pattern (and the color of
|
40
|
+
it)
|
41
|
+
. remove a specified mark (from a "watermark pattern file" provided by step 2)
|
42
|
+
from a series of input images. These input images may or may not contain this
|
43
|
+
watermark.
|
44
|
+
|
45
|
+
== Usage (library)
|
46
|
+
|
47
|
+
TODO: under development.
|
48
|
+
|
49
|
+
== Usage (command-line)
|
50
|
+
|
51
|
+
=== Detection
|
52
|
+
|
53
|
+
The command shall do the following.
|
54
|
+
|
55
|
+
1. The command shall take the input of a PDF / image(s)
|
56
|
+
2. The command outputs a file that contains the detected watermark(s)
|
57
|
+
|
58
|
+
This is the sample help output for `despeck extract`.
|
59
|
+
|
60
|
+
[source]
|
61
|
+
----
|
62
|
+
$ despeck extract -h
|
63
|
+
|
64
|
+
Usage:
|
65
|
+
despeck extract [options] <inputfile> <outputfile>
|
66
|
+
|
67
|
+
[-s sensitivity]
|
68
|
+
An integer value from 0 to 100 to indicate sensitivity of the watermark
|
69
|
+
detection algorithm.
|
70
|
+
|
71
|
+
[-w watermark-color-hint-in-RGB]
|
72
|
+
One or more RGB 8-bit values in hexadecimal (0x00 to 0xFF), separated by
|
73
|
+
commas for each RGB channel, to indicate the approximate color of the
|
74
|
+
watermark.
|
75
|
+
|
76
|
+
The significant bits (0 to 8) should be indicated after the full
|
77
|
+
color hexadecimal value. Example: "FF,AA,88/6" to indicate that the last 2
|
78
|
+
bits of this color value are to be ignored.
|
79
|
+
|
80
|
+
<inputfile>
|
81
|
+
The input file(s)
|
82
|
+
|
83
|
+
<outputfile>
|
84
|
+
The file to output the watermark image to.
|
85
|
+
|
86
|
+
If multiple watermark candidates are detected, multiple watermark images
|
87
|
+
----
|
88
|
+
|
89
|
+
|
90
|
+
=== Removal
|
91
|
+
|
92
|
+
1. The command shall take the input of a PDF / image(s) and the watermark image
|
93
|
+
2. The command outputs a file that does not contain the watermark
|
94
|
+
|
95
|
+
Internally, it:
|
96
|
+
|
97
|
+
1. Investigates each page and detect which ones has a watermark.
|
98
|
+
2. For pages that do not contain the mark, just output it to the output file.
|
99
|
+
3. For the pages that contain the watermark, remove the mark and output to the output file.
|
100
|
+
4. Output the final PDF that all pages have the watermark removed.
|
101
|
+
|
102
|
+
This is the sample help output for `despeck remove`.
|
103
|
+
|
104
|
+
[source]
|
105
|
+
----
|
106
|
+
$ despeck remove -h
|
107
|
+
|
108
|
+
Usage:
|
109
|
+
despeck remove [options] <inputfile> <watermarkfile> <outputfile>
|
110
|
+
|
111
|
+
This command removes the watermark specified in <watermarkfile> from
|
112
|
+
<inputfile>, and outputs the resulting image(s) in outputfile.
|
113
|
+
|
114
|
+
[-s sensitivity]
|
115
|
+
An integer value from 0 to 100 to indicate sensitivity of the watermark
|
116
|
+
removal algorithm.
|
117
|
+
|
118
|
+
<inputfile>
|
119
|
+
The input file(s)
|
120
|
+
|
121
|
+
<watermarkfile>
|
122
|
+
The watermark file
|
123
|
+
|
124
|
+
<outputfile>
|
125
|
+
The file to output the resulting images that have the specified watermark
|
126
|
+
removed.
|
127
|
+
----
|
128
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "despeck"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/despeck.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "despeck/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "despeck"
|
8
|
+
spec.version = Despeck::VERSION
|
9
|
+
spec.authors = ["Ribose Inc."]
|
10
|
+
spec.email = ["open.source@ribose.com"]
|
11
|
+
|
12
|
+
spec.summary = 'Removes stamps and watermarks from scanned images for OCR, "removes specks"'
|
13
|
+
spec.description = 'Removes stamps and watermarks from scanned images for OCR, "removes specks"'
|
14
|
+
|
15
|
+
spec.homepage = "https://github.com/riboseinc/despeck"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
end
|
data/lib/despeck.rb
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: despeck
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ribose Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Removes stamps and watermarks from scanned images for OCR, "removes specks"
|
56
|
+
email:
|
57
|
+
- open.source@ribose.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- CODE_OF_CONDUCT.md
|
64
|
+
- Gemfile
|
65
|
+
- README.adoc
|
66
|
+
- Rakefile
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
69
|
+
- despeck.gemspec
|
70
|
+
- lib/despeck.rb
|
71
|
+
- lib/despeck/version.rb
|
72
|
+
- samples/red-circle/10-06.pdf
|
73
|
+
- samples/red-circle/10-08.pdf
|
74
|
+
- samples/red-circle/10-09.pdf
|
75
|
+
- samples/red-circle/10-11.pdf
|
76
|
+
- samples/red-circle/a-despecked.jpg
|
77
|
+
- samples/red-circle/a.jpg
|
78
|
+
- samples/red-circle/b.jpg
|
79
|
+
- samples/red-circle/c.jpg
|
80
|
+
- samples/red-circle/despecked-portion-parameters.png
|
81
|
+
- samples/red-circle/despecked-portion.png
|
82
|
+
- samples/red-circle/despecked-watermark-parameters.png
|
83
|
+
- samples/red-circle/despecked-watermark.png
|
84
|
+
homepage: https://github.com/riboseinc/despeck
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.6.14
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Removes stamps and watermarks from scanned images for OCR, "removes specks"
|
108
|
+
test_files: []
|