Пример #1
0
func TestCorrBankStrideNaive_vsDecimate(t *testing.T) {
	const (
		numOut = 4
		eps    = 1e-9
	)
	for _, q := range strideCases {
		f := randImage(q.ImSize.X, q.ImSize.Y)
		g := randBank(q.TmplSize.X, q.TmplSize.Y, numOut)
		h, err := slide.CorrBankNaive(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.CorrBankStrideNaive(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
		}
	}
}
Пример #2
0
func TestCorrBankFFT_vsNaive(t *testing.T) {
	const (
		m      = 40
		n      = 30
		w      = 100
		h      = 80
		numOut = 6
		eps    = 1e-9
	)
	f := randImage(w, h)
	g := randBank(w, h, numOut)
	naive, err := slide.CorrBankNaive(f, g)
	if err != nil {
		t.Fatal(err)
	}
	fft, err := slide.CorrBankFFT(f, g)
	if err != nil {
		t.Fatal(err)
	}
	if err := errIfNotEqMulti(naive, fft, eps); err != nil {
		t.Fatal(err)
	}
}