summaryrefslogtreecommitdiff
path: root/sauvola.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-07-26 23:44:41 +0100
committerNick White <git@njw.name>2020-07-26 23:44:41 +0100
commit97753052db0239d907631d4a480ac742412827d3 (patch)
treec7cb6650ac3f540b6a429f621c1c5b9b8e5d0884 /sauvola.go
parent797a8dca9408eb58620bc33dde9b5da51bbfee5f (diff)
Switch to integralimg 0.3.0 and use the new functions for integral sauvola
Diffstat (limited to 'sauvola.go')
-rw-r--r--sauvola.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/sauvola.go b/sauvola.go
index 9eef01b..49181de 100644
--- a/sauvola.go
+++ b/sauvola.go
@@ -61,7 +61,8 @@ func PreCalcedSauvola(intImg integralimg.Image, intSqImg integralimg.SqImage, im
for y := b.Min.Y; y < b.Max.Y; y++ {
for x := b.Min.X; x < b.Max.X; x++ {
- m, dev := integralimg.MeanStdDevWindow(intImg, intSqImg, x, y, windowsize)
+ r := centeredRectangle(x, y, windowsize)
+ m, dev := integralimg.MeanStdDev(intImg, intSqImg, r)
// Divide by 255 to adjust from Gray16 used by integralimg to 8 bit Gray
m8 := m / 255
dev8 := dev / 255
@@ -76,3 +77,8 @@ func PreCalcedSauvola(intImg integralimg.Image, intSqImg integralimg.SqImage, im
return new
}
+
+func centeredRectangle(x, y, size int) image.Rectangle {
+ step := size / 2
+ return image.Rect(x - step - 1, y - step - 1, x + step, y + step)
+}