From 579b7b293feb01af6c47104ac56394cd3fbd1695 Mon Sep 17 00:00:00 2001 From: Nick White Date: Thu, 23 Jul 2020 16:33:30 +0100 Subject: Add SqImage type, which also implements image.Image and image/draw.Image This is intended as an alternative to the WithSq and ToSqIntegralImg functionality, though the MeanStdDevWindow function will need to be changed to use it, and it hasn't been heavily tested yet. --- integralimg_test.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'integralimg_test.go') diff --git a/integralimg_test.go b/integralimg_test.go index df97caa..8b882db 100644 --- a/integralimg_test.go +++ b/integralimg_test.go @@ -28,7 +28,27 @@ func TestFromPNG(t *testing.T) { draw.Draw(integral, b, img, b.Min, draw.Src) if !imgsequal(img, integral) { - t.Errorf("Read png image differs to integral\n") + t.Errorf("Read png image differs to integral image\n") + } +} + +func TestSqFromPNG(t *testing.T) { + f, err := os.Open("testdata/in.png") + if err != nil { + t.Fatalf("Could not open file %s: %v\n", "testdata/in.png", err) + } + defer f.Close() + img, _, err := image.Decode(f) + if err != nil { + t.Fatalf("Could not decode image: %v\n", err) + } + b := img.Bounds() + + integral := NewSqImage(image.Rect(0, 0, b.Dx(), b.Dy())) + draw.Draw(integral, b, img, b.Min, draw.Src) + + if !imgsequal(img, integral) { + t.Errorf("Read png image differs to square integral image\n") } } -- cgit v1.2.1-24-ge1ad