summaryrefslogtreecommitdiff
path: root/sauvola.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-08-04 16:19:01 +0100
committerNick White <git@njw.name>2020-08-04 16:19:01 +0100
commitaa5bd02bd5ed5a6a8d371f953ef128fce64e61a7 (patch)
treee6512607ffc22727ea6cd3cb25bc7db9a4054976 /sauvola.go
parentb26cb9182b566acac884627d790b0660c4766b62 (diff)
Update to replace integralimg package with integral package
Diffstat (limited to 'sauvola.go')
-rw-r--r--sauvola.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/sauvola.go b/sauvola.go
index 49181de..75d558c 100644
--- a/sauvola.go
+++ b/sauvola.go
@@ -10,7 +10,7 @@ import (
"image/draw"
"math"
- "rescribe.xyz/integralimg"
+ "rescribe.xyz/integral"
)
// Implements Sauvola's algorithm for text binarization, see paper
@@ -44,16 +44,16 @@ func Sauvola(img image.Image, ksize float64, windowsize int) *image.Gray {
func IntegralSauvola(img image.Image, ksize float64, windowsize int) *image.Gray {
b := img.Bounds()
- intImg := integralimg.NewImage(b)
+ intImg := integral.NewImage(b)
draw.Draw(intImg, b, img, b.Min, draw.Src)
- intSqImg := integralimg.NewSqImage(b)
+ intSqImg := integral.NewSqImage(b)
draw.Draw(intSqImg, b, img, b.Min, draw.Src)
return PreCalcedSauvola(*intImg, *intSqImg, img, ksize, windowsize)
}
// PreCalcedSauvola Implements Sauvola's algorithm using precalculated Integral Images
-func PreCalcedSauvola(intImg integralimg.Image, intSqImg integralimg.SqImage, img image.Image, ksize float64, windowsize int) *image.Gray {
+func PreCalcedSauvola(intImg integral.Image, intSqImg integral.SqImage, img image.Image, ksize float64, windowsize int) *image.Gray {
b := img.Bounds()
gray := image.NewGray(b)
draw.Draw(gray, b, img, b.Min, draw.Src)
@@ -62,8 +62,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++ {
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
+ m, dev := integral.MeanStdDev(intImg, intSqImg, r)
+ // Divide by 255 to adjust from Gray16 used by integral.Image to 8 bit Gray
m8 := m / 255
dev8 := dev / 255
threshold := m8 * (1 + ksize*((dev8/128)-1))