summaryrefslogtreecommitdiff
path: root/integralimg_test.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-07-23 16:33:30 +0100
committerNick White <git@njw.name>2020-07-23 16:33:30 +0100
commit579b7b293feb01af6c47104ac56394cd3fbd1695 (patch)
tree8b6ca79b992f711dc3b059fe2b9b2f3585b979f5 /integralimg_test.go
parentd9c6a724e97141db9cbaa66226e0410a5535ae28 (diff)
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.
Diffstat (limited to 'integralimg_test.go')
-rw-r--r--integralimg_test.go22
1 files changed, 21 insertions, 1 deletions
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")
}
}