summaryrefslogtreecommitdiff
path: root/preproc
diff options
context:
space:
mode:
Diffstat (limited to 'preproc')
-rw-r--r--preproc/cmd/binarize/main.go2
-rw-r--r--preproc/cmd/preproc/main.go2
-rw-r--r--preproc/cmd/preprocmulti/main.go2
-rw-r--r--preproc/sauvola.go6
-rw-r--r--preproc/sauvola_test.go10
-rw-r--r--preproc/util.go6
-rw-r--r--preproc/wipesides.go2
7 files changed, 15 insertions, 15 deletions
diff --git a/preproc/cmd/binarize/main.go b/preproc/cmd/binarize/main.go
index c274f9c..e7f677e 100644
--- a/preproc/cmd/binarize/main.go
+++ b/preproc/cmd/binarize/main.go
@@ -50,7 +50,7 @@ func main() {
log.Printf("Set window size to %d\n", *wsize)
}
- if *wsize % 2 == 0 {
+ if *wsize%2 == 0 {
*wsize++
}
diff --git a/preproc/cmd/preproc/main.go b/preproc/cmd/preproc/main.go
index 92e8509..053de8f 100644
--- a/preproc/cmd/preproc/main.go
+++ b/preproc/cmd/preproc/main.go
@@ -55,7 +55,7 @@ func main() {
*binwsize = autowsize(b)
}
- if *binwsize % 2 == 0 {
+ if *binwsize%2 == 0 {
*binwsize++
}
diff --git a/preproc/cmd/preprocmulti/main.go b/preproc/cmd/preprocmulti/main.go
index a159938..01afb9b 100644
--- a/preproc/cmd/preprocmulti/main.go
+++ b/preproc/cmd/preprocmulti/main.go
@@ -57,7 +57,7 @@ func main() {
*binwsize = autowsize(b)
}
- if *binwsize % 2 == 0 {
+ if *binwsize%2 == 0 {
*binwsize++
}
diff --git a/preproc/sauvola.go b/preproc/sauvola.go
index 2ed9a92..046bb7d 100644
--- a/preproc/sauvola.go
+++ b/preproc/sauvola.go
@@ -17,7 +17,7 @@ func Sauvola(img *image.Gray, ksize float64, windowsize int) *image.Gray {
for x := b.Min.X; x < b.Max.X; x++ {
window := surrounding(img, x, y, windowsize)
m, dev := meanstddev(window)
- threshold := m * (1 + ksize * ((dev / 128) - 1))
+ threshold := m * (1 + ksize*((dev/128)-1))
if img.GrayAt(x, y).Y < uint8(threshold) {
new.SetGray(x, y, color.Gray{0})
} else {
@@ -42,7 +42,7 @@ func IntegralSauvola(img *image.Gray, ksize float64, windowsize int) *image.Gray
for y := b.Min.Y; y < b.Max.Y; y++ {
for x := b.Min.X; x < b.Max.X; x++ {
m, dev := integrals.MeanStdDevWindow(x, y, windowsize)
- threshold := m * (1 + ksize * ((dev / 128) - 1))
+ threshold := m * (1 + ksize*((dev/128)-1))
if img.GrayAt(x, y).Y < uint8(threshold) {
new.SetGray(x, y, color.Gray{0})
} else {
@@ -63,7 +63,7 @@ func PreCalcedSauvola(integrals integralimg.WithSq, img *image.Gray, ksize float
for y := b.Min.Y; y < b.Max.Y; y++ {
for x := b.Min.X; x < b.Max.X; x++ {
m, dev := integrals.MeanStdDevWindow(x, y, windowsize)
- threshold := m * (1 + ksize * ((dev / 128) - 1))
+ threshold := m * (1 + ksize*((dev/128)-1))
if img.GrayAt(x, y).Y < uint8(threshold) {
new.SetGray(x, y, color.Gray{0})
} else {
diff --git a/preproc/sauvola_test.go b/preproc/sauvola_test.go
index deefb96..2331e10 100644
--- a/preproc/sauvola_test.go
+++ b/preproc/sauvola_test.go
@@ -14,11 +14,11 @@ func TestBinarization(t *testing.T) {
var update = flag.Bool("updatesauvola", false, "update golden files")
cases := []struct {
- name string
- orig string
+ name string
+ orig string
golden string
- ksize float64
- wsize int
+ ksize float64
+ wsize int
}{
{"integralsauvola", "testdata/pg1.png", "testdata/pg1_integralsauvola_k0.5_w41.png", 0.5, 41},
{"integralsauvola", "testdata/pg1.png", "testdata/pg1_integralsauvola_k0.5_w19.png", 0.5, 19},
@@ -62,7 +62,7 @@ func TestBinarization(t *testing.T) {
if err != nil {
t.Fatalf("Could not open file %s: %v\n", c.golden, err)
}
- if ! imgsequal(golden, actual) {
+ if !imgsequal(golden, actual) {
t.Errorf("Binarized %s differs to %s\n", c.orig, c.golden)
}
})
diff --git a/preproc/util.go b/preproc/util.go
index 5f8a9f1..e23829d 100644
--- a/preproc/util.go
+++ b/preproc/util.go
@@ -29,7 +29,7 @@ func stddev(i []int) float64 {
for _, n := range i {
sum += (float64(n) - m) * (float64(n) - m)
}
- variance := sum / float64(len(i) - 1)
+ variance := sum / float64(len(i)-1)
return math.Sqrt(variance)
}
@@ -40,7 +40,7 @@ func meanstddev(i []int) (float64, float64) {
for _, n := range i {
sum += (float64(n) - m) * (float64(n) - m)
}
- variance := float64(sum) / float64(len(i) - 1)
+ variance := float64(sum) / float64(len(i)-1)
return m, math.Sqrt(variance)
}
@@ -77,7 +77,7 @@ func surrounding(img *image.Gray, x int, y int, size int) []int {
func BinToZeroInv(bin *image.Gray, orig *image.RGBA) (*image.RGBA, error) {
b := bin.Bounds()
- if ! b.Eq(orig.Bounds()) {
+ if !b.Eq(orig.Bounds()) {
return orig, errors.New("bin and orig images need to be the same dimensions")
}
newimg := image.NewRGBA(image.Rect(0, 0, b.Dx(), b.Dy()))
diff --git a/preproc/wipesides.go b/preproc/wipesides.go
index 5291d00..04bfa11 100644
--- a/preproc/wipesides.go
+++ b/preproc/wipesides.go
@@ -12,7 +12,7 @@ import (
// returns the proportion of the given window that is black pixels
func proportion(i integralimg.I, x int, size int) float64 {
- w := i.GetVerticalWindow(x, size)
+ w := i.GetVerticalWindow(x, size)
return w.Proportion()
}