forked from viamrobotics/rdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilters_test.go
24 lines (21 loc) · 883 Bytes
/
filters_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
package rimage
import (
"testing"
"go.viam.com/test"
)
func TestSavitskyGolay(t *testing.T) {
expected := [][]float64{
{-0.0742857142857142, 0.01142857142857133, 0.040000000000000036, 0.01142857142857142, -0.0742857142857143},
{0.011428571428571434, 0.09714285714285709, 0.1257142857142857, 0.09714285714285716, 0.011428571428571496},
{0.040000000000000015, 0.12571428571428572, 0.1542857142857143, 0.12571428571428575, 0.04000000000000007},
{0.011428571428571434, 0.09714285714285714, 0.1257142857142857, 0.09714285714285714, 0.011428571428571439},
{-0.0742857142857143, 0.01142857142857143, 0.03999999999999997, 0.011428571428571392, -0.07428571428571429},
}
got, err := savitskyGolayKernel(2, 2)
test.That(t, err, test.ShouldBeNil)
for i := 0; i < 5; i++ {
for j := 0; j < 5; j++ {
test.That(t, expected[i][j], test.ShouldAlmostEqual, got[i][j])
}
}
}