diff options
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 4 | ||||
-rw-r--r-- | sauvola.go | 8 | ||||
-rw-r--r-- | testdata/pg1_integralsauvola_k0.3_w19.png | bin | 19618 -> 19620 bytes | |||
-rw-r--r-- | testdata/pg1_integralsauvola_k0.5_w19.png | bin | 18439 -> 18435 bytes | |||
-rw-r--r-- | testdata/pg1_integralsauvola_k0.5_w41.png | bin | 18284 -> 18282 bytes |
6 files changed, 10 insertions, 4 deletions
@@ -7,5 +7,5 @@ require ( github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/wcharczuk/go-chart v2.0.2-0.20191206192251-962b9abdec2b+incompatible golang.org/x/image v0.0.0-20200618115811-c13761719519 // indirect - rescribe.xyz/integralimg v0.2.1 + rescribe.xyz/integralimg v0.3.0 ) @@ -16,5 +16,5 @@ golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20181205014116-22934f0fdb62/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -rescribe.xyz/integralimg v0.2.1 h1:OhYifujtlVGYm/WfLl8ios/bouzIWcwuzbRyCZQiab0= -rescribe.xyz/integralimg v0.2.1/go.mod h1:2euyPigpyIixTWO6JtFEhDp/3YKA6yy+d8g17oL0L0s= +rescribe.xyz/integralimg v0.3.0 h1:G5/yR8jKtewLlCEkygg7T8h1nllwNt4SmLdw+1fCsE4= +rescribe.xyz/integralimg v0.3.0/go.mod h1:2euyPigpyIixTWO6JtFEhDp/3YKA6yy+d8g17oL0L0s= @@ -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) +} diff --git a/testdata/pg1_integralsauvola_k0.3_w19.png b/testdata/pg1_integralsauvola_k0.3_w19.png Binary files differindex 00aa1d8..a648969 100644 --- a/testdata/pg1_integralsauvola_k0.3_w19.png +++ b/testdata/pg1_integralsauvola_k0.3_w19.png diff --git a/testdata/pg1_integralsauvola_k0.5_w19.png b/testdata/pg1_integralsauvola_k0.5_w19.png Binary files differindex 77a7194..86c0104 100644 --- a/testdata/pg1_integralsauvola_k0.5_w19.png +++ b/testdata/pg1_integralsauvola_k0.5_w19.png diff --git a/testdata/pg1_integralsauvola_k0.5_w41.png b/testdata/pg1_integralsauvola_k0.5_w41.png Binary files differindex 5ddc854..5b003f1 100644 --- a/testdata/pg1_integralsauvola_k0.5_w41.png +++ b/testdata/pg1_integralsauvola_k0.5_w41.png |