summaryrefslogtreecommitdiff
path: root/preprocmulti.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-07-23 23:09:43 +0100
committerNick White <git@njw.name>2020-07-23 23:09:43 +0100
commit1ef9df29fb2d5bb6585e0d0ed99e13a900289e7b (patch)
tree124ddc2d71e3090fa131468cdf22af076a177063 /preprocmulti.go
parent6a36400351bea5052431bb1feace358fa67a5cf9 (diff)
Update to v0.2.1 of integralimg, and improve various things
- Improve integral sauvola by rounding threshold correctly - The Sauvola functions can now process any image.Image, not just an image.Gray - Add ImageWindower interface and use it to generalise wipesides.go - Rely on Bounds() for image bounds rather than implementation- specific stuff in integralimg Note that a couple of the wipesides tests are now failing. It's possible that this is due to fixed or introduced bugs (let's hope the former) changing sensible thresholds. Will need to look into this and sort it.
Diffstat (limited to 'preprocmulti.go')
-rw-r--r--preprocmulti.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/preprocmulti.go b/preprocmulti.go
index e671108..25d35ea 100644
--- a/preprocmulti.go
+++ b/preprocmulti.go
@@ -49,10 +49,8 @@ func PreProcMulti(inPath string, ksizes []float64, binType string, binWsize int,
if err != nil {
return donePaths, err
}
- b := img.Bounds()
- gray := image.NewGray(image.Rect(0, 0, b.Dx(), b.Dy()))
- draw.Draw(gray, b, img, b.Min, draw.Src)
+ b := img.Bounds()
if binWsize == 0 {
binWsize = autowsize(b)
}
@@ -61,11 +59,15 @@ func PreProcMulti(inPath string, ksizes []float64, binType string, binWsize int,
binWsize++
}
+ intImg := integralimg.NewImage(b)
+ draw.Draw(intImg, b, img, b.Min, draw.Src)
+ intSqImg := integralimg.NewSqImage(b)
+ draw.Draw(intSqImg, b, img, b.Min, draw.Src)
+
var clean, threshimg image.Image
- integrals := integralimg.ToAllIntegralImg(gray)
for _, k := range ksizes {
- threshimg = PreCalcedSauvola(integrals, gray, k, binWsize)
+ threshimg = PreCalcedSauvola(*intImg, *intSqImg, img, k, binWsize)
if binType == "zeroinv" {
threshimg, err = BinToZeroInv(threshimg.(*image.Gray), img.(*image.RGBA))