Ejemplo n.º 1
0
func TestCorrMultiBankStrideNaive_vsDecimate(t *testing.T) {
	const (
		numIn  = 3
		numOut = 4
		eps    = 1e-9
	)
	for _, q := range strideCases {
		f := randMulti(q.ImSize.X, q.ImSize.Y, numIn)
		g := randMultiBank(q.TmplSize.X, q.TmplSize.Y, numIn, numOut)
		h, err := slide.CorrMultiBankNaive(f, g)
		if err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
		want := slide.DecimateMulti(h, q.K)
		got, err := slide.CorrMultiBankStrideNaive(f, g, q.K)
		if err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
		if err := errIfNotEqMulti(want, got, eps); err != nil {
			t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err)
			continue
		}
	}
}
Ejemplo n.º 2
0
func TestCorrMultiBankFFT_vsNaive(t *testing.T) {
	const (
		m   = 40
		n   = 30
		w   = 100
		h   = 80
		p   = 4
		q   = 6
		eps = 1e-9
	)
	f := randMulti(w, h, p)
	g := randMultiBank(w, h, p, q)
	naive, err := slide.CorrMultiBankNaive(f, g)
	if err != nil {
		t.Fatal(err)
	}
	fft, err := slide.CorrMultiBankFFT(f, g)
	if err != nil {
		t.Fatal(err)
	}
	if err := errIfNotEqMulti(naive, fft, eps); err != nil {
		t.Fatal(err)
	}
}