summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wipesides.go7
-rw-r--r--wipesides_test.go2
2 files changed, 4 insertions, 5 deletions
diff --git a/wipesides.go b/wipesides.go
index e87d209..a306250 100644
--- a/wipesides.go
+++ b/wipesides.go
@@ -149,13 +149,14 @@ func toonarrow(img *image.Gray, lowedge int, highedge int, min int) bool {
}
// sideways flips an image sideways
-func sideways(img *image.Gray) *image.Gray {
+func sideways(img image.Image) *image.Gray {
b := img.Bounds()
newb := image.Rect(b.Min.Y, b.Min.X, b.Max.Y, b.Max.X)
new := image.NewGray(newb)
for x := b.Min.X; x < b.Max.X; x++ {
for y := b.Min.Y; y < b.Max.Y; y++ {
- new.SetGray(y, x, img.GrayAt(x, y))
+ c := img.At(x, y)
+ new.SetGray(y, x, color.GrayModel.Convert(c).(color.Gray))
}
}
return new
@@ -212,7 +213,7 @@ func WipeFile(inPath string, outPath string, hwsize int, hthresh float64, hmin i
return errors.New(fmt.Sprintf("Could not decode image: %v", err))
}
b := img.Bounds()
- gray := image.NewGray(image.Rect(0, 0, b.Dx(), b.Dy()))
+ gray := image.NewGray(b)
draw.Draw(gray, b, img, b.Min, draw.Src)
vclean := VWipe(gray, vwsize, vthresh, vmin)
diff --git a/wipesides_test.go b/wipesides_test.go
index 8aa68ff..660cb16 100644
--- a/wipesides_test.go
+++ b/wipesides_test.go
@@ -117,8 +117,6 @@ func TestWipeSides(t *testing.T) {
t.Fatalf("Could not open file %s: %v\n", c.filename, err)
}
b := img.Bounds()
- gray := image.NewGray(b)
- draw.Draw(gray, b, img, b.Min, draw.Src)
rotimg := sideways(img)
b = rotimg.Bounds()
intImg := integralimg.NewImage(b)