From e8c47ee22391bc395bc4c8001c8edde9b6eff708 Mon Sep 17 00:00:00 2001 From: Nick White Date: Wed, 4 Mar 2020 17:32:47 +0000 Subject: Add vertical test to wipesides --- testdata/1727_GREENE_0048.png | Bin 0 -> 386687 bytes wipesides_test.go | 42 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 testdata/1727_GREENE_0048.png diff --git a/testdata/1727_GREENE_0048.png b/testdata/1727_GREENE_0048.png new file mode 100644 index 0000000..b8635ba Binary files /dev/null and b/testdata/1727_GREENE_0048.png differ diff --git a/wipesides_test.go b/wipesides_test.go index 36d884e..0c9eb1c 100644 --- a/wipesides_test.go +++ b/wipesides_test.go @@ -57,7 +57,7 @@ func TestWipeSides(t *testing.T) { } }) } - testedgecases := []struct { + leftrightedgecases := []struct { filename string minleft int maxleft int @@ -67,10 +67,11 @@ func TestWipeSides(t *testing.T) { wsize int }{ {"testdata/0002.png", 36, 250, 967, 998, 0.02, 5}, + {"testdata/1727_GREENE_0048.png", 40, 150, 1270, 1281, 0.02, 5}, } - for _, c := range testedgecases { - t.Run(fmt.Sprintf("Edge/%s_%0.2f_%d", c.filename, c.thresh, c.wsize), func(t *testing.T) { + for _, c := range leftrightedgecases { + t.Run(fmt.Sprintf("LeftRightEdge/%s_%0.2f_%d", c.filename, c.thresh, c.wsize), func(t *testing.T) { img, err := decode(c.filename) if err != nil { t.Fatalf("Could not open file %s: %v\n", c.filename, err) @@ -91,4 +92,39 @@ func TestWipeSides(t *testing.T) { } }) } + + topbottomedgecases := []struct { + filename string + mintop int + maxtop int + minbottom int + maxbottom int + thresh float64 + wsize int + }{ + {"testdata/1727_GREENE_0048.png", 172, 237, 2204, 2244, 0.005, 120}, + } + + for _, c := range topbottomedgecases { + t.Run(fmt.Sprintf("TopBottomEdge/%s_%0.2f_%d", c.filename, c.thresh, c.wsize), func(t *testing.T) { + img, err := decode(c.filename) + if err != nil { + t.Fatalf("Could not open file %s: %v\n", c.filename, err) + } + integral := integralimg.ToIntegralImg(sideways(img)) + topedge, bottomedge := findedges(integral, c.wsize, c.thresh) + if topedge < c.mintop { + t.Errorf("Top edge %d < minimum %d", topedge, c.mintop) + } + if topedge > c.maxtop { + t.Errorf("Top edge %d > maximum %d", topedge, c.maxtop) + } + if bottomedge < c.minbottom { + t.Errorf("Bottom edge %d < minimum %d", bottomedge, c.minbottom) + } + if bottomedge > c.maxbottom { + t.Errorf("Bottom edge %d > maximum %d", bottomedge, c.maxbottom) + } + }) + } } -- cgit v1.2.1-24-ge1ad