diff options
author | Nick White <git@njw.name> | 2020-07-24 18:49:50 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2020-07-24 18:49:50 +0100 |
commit | 70e3b595b02977e90c533756a8837c019d51d182 (patch) | |
tree | d4521897db2457585c603d13a1f1e404a9803ce7 /wipesides.go | |
parent | 41abf458640394dcdf63e874e75b5e06aebd0214 (diff) |
Make sideways() work on any image.Image
Diffstat (limited to 'wipesides.go')
-rw-r--r-- | wipesides.go | 7 |
1 files changed, 4 insertions, 3 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) |