diff options
| author | Nick White <git@njw.name> | 2020-03-04 17:32:47 +0000 | 
|---|---|---|
| committer | Nick White <git@njw.name> | 2020-03-04 17:32:47 +0000 | 
| commit | e8c47ee22391bc395bc4c8001c8edde9b6eff708 (patch) | |
| tree | 37fdb77013f62350a47f289cc4e1f65db42d383b | |
| parent | 60071c2ea95e284f6c765528e81b930fe3fb4b92 (diff) | |
Add vertical test to wipesides
| -rw-r--r-- | testdata/1727_GREENE_0048.png | bin | 0 -> 386687 bytes | |||
| -rw-r--r-- | wipesides_test.go | 42 | 
2 files changed, 39 insertions, 3 deletions
diff --git a/testdata/1727_GREENE_0048.png b/testdata/1727_GREENE_0048.png Binary files differnew file mode 100644 index 0000000..b8635ba --- /dev/null +++ b/testdata/1727_GREENE_0048.png 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) +			} +		}) +	}  }  | 
