-
Notifications
You must be signed in to change notification settings - Fork 1
/
fast_bilateral_test.go
72 lines (57 loc) · 1.8 KB
/
fast_bilateral_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package bilateral_test
import (
"image/color"
_ "image/jpeg"
"reflect"
"testing"
"github.com/mdouchement/bilateral"
)
func check(err error) {
if err != nil {
panic(err)
}
}
func TestFastBilateralColor(t *testing.T) {
mi := images["base"]
mo := images["filtered"]
filter := bilateral.Auto(mi)
filter.Execute()
if filter.ColorModel() != color.RGBAModel {
t.Errorf("%s: expected: %#v, actual: %#v", "ColorModel", color.RGBAModel, filter.ColorModel())
}
if !reflect.DeepEqual(filter.Bounds(), mi.Bounds()) {
t.Errorf("%s: expected: %#v, actual: %#v", "Bounds", mi.Bounds(), filter.Bounds())
}
if !reflect.DeepEqual(filter.ResultImage(), mo) {
t.Errorf("%s: expected: %#v, actual: %#v", "ResultImage", mo, filter.ResultImage())
}
for y := 0; y < mi.Bounds().Dy(); y++ {
for x := 0; x < mi.Bounds().Dx(); x++ {
if !reflect.DeepEqual(filter.At(x, y), mo.At(x, y)) {
t.Errorf("%s(%d,%d): expected: %#v, actual: %#v", "At", x, y, mo.At(x, y), filter.At(x, y))
}
}
}
}
func TestFastBilateralGray(t *testing.T) {
mi := images["base-gray"]
mo := images["base-gray-filtered"]
filter := bilateral.Auto(mi)
filter.Execute()
if filter.ColorModel() != color.RGBAModel {
t.Errorf("%s: expected: %#v, actual: %#v", "ColorModel", color.RGBAModel, filter.ColorModel())
}
if !reflect.DeepEqual(filter.Bounds(), mi.Bounds()) {
t.Errorf("%s: expected: %#v, actual: %#v", "Bounds", mi.Bounds(), filter.Bounds())
}
if !reflect.DeepEqual(filter.ResultImage(), mo) {
t.Errorf("%s: expected: %#v, actual: %#v", "ResultImage", mo, filter.ResultImage())
}
for y := 0; y < mi.Bounds().Dy(); y++ {
for x := 0; x < mi.Bounds().Dx(); x++ {
if !reflect.DeepEqual(filter.At(x, y), mo.At(x, y)) {
t.Errorf("%s(%d,%d): expected: %#v, actual: %#v", "At", x, y, mo.At(x, y), filter.At(x, y))
}
}
}
}