diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2015-09-17 11:08:47 -0400 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2015-09-17 19:13:42 -0400 |
commit | d83be6df2d8b0e2fef4cb6866cfdb6434bbef5c4 (patch) | |
tree | a4677163f2aa762c75988fe402b9aea89d95e0be /Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/detect/detect_test.go | |
parent | 82127341cacd4299f9a59e76b5f68d6d7222c45b (diff) | |
download | chat-d83be6df2d8b0e2fef4cb6866cfdb6434bbef5c4.tar.gz chat-d83be6df2d8b0e2fef4cb6866cfdb6434bbef5c4.tar.bz2 chat-d83be6df2d8b0e2fef4cb6866cfdb6434bbef5c4.zip |
PLT-173 Added graphics-go and goexif libraries for image manipulation
Diffstat (limited to 'Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/detect/detect_test.go')
-rw-r--r-- | Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/detect/detect_test.go | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/detect/detect_test.go b/Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/detect/detect_test.go new file mode 100644 index 000000000..8a2df113d --- /dev/null +++ b/Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/detect/detect_test.go @@ -0,0 +1,77 @@ +// Copyright 2011 The Graphics-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package detect + +import ( + "image" + "image/draw" + "testing" +) + +var ( + c0 = Classifier{ + Feature: []Feature{ + Feature{Rect: image.Rect(0, 0, 3, 4), Weight: 4.0}, + }, + Threshold: 0.2, + Left: 0.8, + Right: 0.2, + } + c1 = Classifier{ + Feature: []Feature{ + Feature{Rect: image.Rect(3, 4, 4, 5), Weight: 4.0}, + }, + Threshold: 0.2, + Left: 0.8, + Right: 0.2, + } + c2 = Classifier{ + Feature: []Feature{ + Feature{Rect: image.Rect(0, 0, 1, 1), Weight: +4.0}, + Feature{Rect: image.Rect(0, 0, 2, 2), Weight: -1.0}, + }, + Threshold: 0.2, + Left: 0.8, + Right: 0.2, + } +) + +func TestClassifier(t *testing.T) { + m := image.NewGray(image.Rect(0, 0, 20, 20)) + b := m.Bounds() + draw.Draw(m, image.Rect(0, 0, 20, 20), image.White, image.ZP, draw.Src) + draw.Draw(m, image.Rect(3, 4, 4, 5), image.Black, image.ZP, draw.Src) + w := newWindow(m) + pr := newProjector(b, b) + + if res := c0.classify(w, pr); res != c0.Right { + t.Errorf("c0 got %f want %f", res, c0.Right) + } + if res := c1.classify(w, pr); res != c1.Left { + t.Errorf("c1 got %f want %f", res, c1.Left) + } + if res := c2.classify(w, pr); res != c1.Left { + t.Errorf("c2 got %f want %f", res, c1.Left) + } +} + +func TestClassifierScale(t *testing.T) { + m := image.NewGray(image.Rect(0, 0, 50, 50)) + b := m.Bounds() + draw.Draw(m, image.Rect(0, 0, 8, 10), image.White, b.Min, draw.Src) + draw.Draw(m, image.Rect(8, 10, 10, 13), image.Black, b.Min, draw.Src) + w := newWindow(m) + pr := newProjector(b, image.Rect(0, 0, 20, 20)) + + if res := c0.classify(w, pr); res != c0.Right { + t.Errorf("scaled c0 got %f want %f", res, c0.Right) + } + if res := c1.classify(w, pr); res != c1.Left { + t.Errorf("scaled c1 got %f want %f", res, c1.Left) + } + if res := c2.classify(w, pr); res != c1.Left { + t.Errorf("scaled c2 got %f want %f", res, c1.Left) + } +} |