summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-08-04 16:59:43 +0100
committerNick White <git@njw.name>2020-08-04 16:59:43 +0100
commit38e235f95895d96c03be4e64ce4263eaac477687 (patch)
tree3b1f50ad2e7f81bb39cd5b14c2754976a7fa93b6
parentaa5bd02bd5ed5a6a8d371f953ef128fce64e61a7 (diff)
Improve sauvola window code slightly
The sauvola and integral image version are still slightly different, irritatingly.
-rw-r--r--testdata/pg1_sauvola_k0.3_w19.pngbin19512 -> 19626 bytes
-rw-r--r--testdata/pg1_sauvola_k0.5_w19.pngbin18354 -> 18144 bytes
-rw-r--r--testdata/pg1_sauvola_k0.5_w41.pngbin18275 -> 18220 bytes
-rw-r--r--util.go8
4 files changed, 4 insertions, 4 deletions
diff --git a/testdata/pg1_sauvola_k0.3_w19.png b/testdata/pg1_sauvola_k0.3_w19.png
index e964b19..c357a8a 100644
--- a/testdata/pg1_sauvola_k0.3_w19.png
+++ b/testdata/pg1_sauvola_k0.3_w19.png
Binary files differ
diff --git a/testdata/pg1_sauvola_k0.5_w19.png b/testdata/pg1_sauvola_k0.5_w19.png
index 780fc4f..a063b28 100644
--- a/testdata/pg1_sauvola_k0.5_w19.png
+++ b/testdata/pg1_sauvola_k0.5_w19.png
Binary files differ
diff --git a/testdata/pg1_sauvola_k0.5_w41.png b/testdata/pg1_sauvola_k0.5_w41.png
index acce4f3..4544da3 100644
--- a/testdata/pg1_sauvola_k0.5_w41.png
+++ b/testdata/pg1_sauvola_k0.5_w41.png
Binary files differ
diff --git a/util.go b/util.go
index 7cbaebc..52026cb 100644
--- a/util.go
+++ b/util.go
@@ -50,11 +50,11 @@ func surrounding(img *image.Gray, x int, y int, size int) []int {
b := img.Bounds()
step := size / 2
- miny := y - step
+ miny := y - step - 1
if miny < b.Min.Y {
miny = b.Min.Y
}
- minx := x - step
+ minx := x - step - 1
if minx < b.Min.X {
minx = b.Min.X
}
@@ -68,8 +68,8 @@ func surrounding(img *image.Gray, x int, y int, size int) []int {
}
var s []int
- for yi := miny; yi <= maxy; yi++ {
- for xi := minx; xi <= maxx; xi++ {
+ for yi := miny; yi < maxy; yi++ {
+ for xi := minx; xi < maxx; xi++ {
s = append(s, int(img.GrayAt(xi, yi).Y))
}
}