summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-04-14 11:37:57 +0100
committerNick White <git@njw.name>2020-04-14 11:37:57 +0100
commit014af190c64b2fecbf5d69e9a13e45858e830e81 (patch)
treec8398b8b2b224f13309156b0554c7aa80bccfdc8
parent822ce40a7d708ed44d6e638e2e25db9261254d13 (diff)
Improve documentation throughout
-rw-r--r--cmd/binarize/main.go1
-rw-r--r--cmd/preproc/main.go1
-rw-r--r--cmd/preprocmulti/main.go2
-rw-r--r--cmd/splittable/main.go2
-rw-r--r--cmd/wipe/main.go2
-rw-r--r--doc.go9
-rw-r--r--preprocmulti.go12
-rw-r--r--sauvola.go2
-rw-r--r--util.go6
9 files changed, 26 insertions, 11 deletions
diff --git a/cmd/binarize/main.go b/cmd/binarize/main.go
index a844982..c7cadb2 100644
--- a/cmd/binarize/main.go
+++ b/cmd/binarize/main.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by the GPLv3
// license that can be found in the LICENSE file.
+// binarize does fast Integral Image sauvola binarisation on an image
package main
import (
diff --git a/cmd/preproc/main.go b/cmd/preproc/main.go
index 3323635..e967cd2 100644
--- a/cmd/preproc/main.go
+++ b/cmd/preproc/main.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by the GPLv3
// license that can be found in the LICENSE file.
+// preproc runs binarisation and wipe preprocessing on an image
package main
// TODO: come up with a way to set a good ksize automatically
diff --git a/cmd/preprocmulti/main.go b/cmd/preprocmulti/main.go
index ca7799f..911c791 100644
--- a/cmd/preprocmulti/main.go
+++ b/cmd/preprocmulti/main.go
@@ -2,6 +2,8 @@
// Use of this source code is governed by the GPLv3
// license that can be found in the LICENSE file.
+// preprocmulti runs binarisation with a variety of different binarisation
+// levels, preprocessing and saving each version
package main
// TODO: come up with a way to set a good ksize automatically
diff --git a/cmd/splittable/main.go b/cmd/splittable/main.go
index 9055cf8..ff5082b 100644
--- a/cmd/splittable/main.go
+++ b/cmd/splittable/main.go
@@ -2,6 +2,8 @@
// Use of this source code is governed by the GPLv3
// license that can be found in the LICENSE file.
+// splittable is an experimental program to split a table into
+// individual cells suitable for OCR
package main
import (
diff --git a/cmd/wipe/main.go b/cmd/wipe/main.go
index beeced2..30b0061 100644
--- a/cmd/wipe/main.go
+++ b/cmd/wipe/main.go
@@ -2,6 +2,8 @@
// Use of this source code is governed by the GPLv3
// license that can be found in the LICENSE file.
+// wipe wipes sections of an image which are outside of an automatically
+// determined content area
package main
import (
diff --git a/doc.go b/doc.go
new file mode 100644
index 0000000..0fffdd9
--- /dev/null
+++ b/doc.go
@@ -0,0 +1,9 @@
+// Copyright 2020 Nick White.
+// Use of this source code is governed by the GPLv3
+// license that can be found in the LICENSE file.
+
+// preproc contains various image processing methods which are useful
+// for preprocessing page images for OCR. It contains both library
+// functions to incorporate into your own projects and standalone
+// tools which can be used directly.
+package preproc
diff --git a/preprocmulti.go b/preprocmulti.go
index 427ffe7..e671108 100644
--- a/preprocmulti.go
+++ b/preprocmulti.go
@@ -4,8 +4,6 @@
package preproc
-// TODO: come up with a way to set a good ksize automatically
-
import (
"fmt"
"image"
@@ -18,8 +16,8 @@ import (
"rescribe.xyz/integralimg"
)
-// TODO: do more testing to see how good this assumption is
func autowsize(bounds image.Rectangle) int {
+ // TODO: do more testing to see how good this assumption is
return bounds.Dx() / 60
}
@@ -31,11 +29,11 @@ func autowsize(bounds image.Rectangle) int {
// wipe: Whether to wipe (clear sides) the image
// wipeWsize: Window size for wiping algorithm
// wipeMinWidthPerc: Minimum percentage of the image width for the content width calculation to be considered valid
-// Note: copied from cmd/preprocmulti/main.go, should think about the best way
-// to organise this code later.
-// TODO: return errors that encapsulate the err describing where it was encountered
-// TODO: do the post-integral image stuff in separate goroutines for speed
func PreProcMulti(inPath string, ksizes []float64, binType string, binWsize int, wipe bool, wipeWsize int, wipeMinWidthPerc int) ([]string, error) {
+ // Note: copied from cmd/preprocmulti/main.go, should think about the best way to organise this code later.
+ // TODO: return errors that encapsulate the err describing where it was encountered
+ // TODO: come up with a way to set a good ksize automatically
+
// Make outBase inPath up to final .
s := strings.Split(inPath, ".")
outBase := strings.Join(s[:len(s)-1], "")
diff --git a/sauvola.go b/sauvola.go
index c512098..bea78ce 100644
--- a/sauvola.go
+++ b/sauvola.go
@@ -59,8 +59,8 @@ func IntegralSauvola(img *image.Gray, ksize float64, windowsize int) *image.Gray
}
// PreCalcedSauvola Implements Sauvola's algorithm using precalculated Integral Images
-// TODO: have this be the root function that the other two reference
func PreCalcedSauvola(integrals integralimg.WithSq, img *image.Gray, ksize float64, windowsize int) *image.Gray {
+ // TODO: have this be the root function that the other two reference
b := img.Bounds()
new := image.NewGray(b)
diff --git a/util.go b/util.go
index 3ce4f84..f0864e9 100644
--- a/util.go
+++ b/util.go
@@ -10,10 +10,10 @@ import (
"math"
)
-// TODO: name better; maybe verb, x-er
-// TODO: implement these for regular image, and use them to make
-// image functions generic for integral and non- images
type UsefulImg interface {
+ // TODO: name better; maybe verb, x-er
+ // TODO: implement these for regular image, and use them to make
+ // image functions generic for integral and non- images
MeanWindow()
MeanStdDevWindow()
}