From b8834fa3a6204996d8cc8d6ee13c1fa05a65d42e Mon Sep 17 00:00:00 2001 From: wiredfool Date: Thu, 19 Jun 2014 14:55:43 -0700 Subject: [PATCH] Additional tests, tests in functions --- Tests/images/corner.lut | Bin 0 -> 512 bytes Tests/images/dilation4.lut | Bin 0 -> 512 bytes Tests/images/dilation8.lut | Bin 0 -> 512 bytes Tests/images/edge.lut | Bin 0 -> 512 bytes Tests/images/erosion4.lut | Bin 0 -> 512 bytes Tests/images/erosion8.lut | Bin 0 -> 512 bytes Tests/images/morph_a.png | Bin 0 -> 83 bytes Tests/test_imagemorph.py | 189 +++++++++++++++++++++---------------- 8 files changed, 109 insertions(+), 80 deletions(-) create mode 100644 Tests/images/corner.lut create mode 100644 Tests/images/dilation4.lut create mode 100644 Tests/images/dilation8.lut create mode 100644 Tests/images/edge.lut create mode 100644 Tests/images/erosion4.lut create mode 100644 Tests/images/erosion8.lut create mode 100644 Tests/images/morph_a.png diff --git a/Tests/images/corner.lut b/Tests/images/corner.lut new file mode 100644 index 0000000000000000000000000000000000000000..7b0386be38826995dc2bbc5e30c935d4b44cfc28 GIT binary patch literal 512 zcmZQzKn09w09BTO0Va(u4&%e*VKht}Ml%8#AdCwz0wuv}a3})H;nEBgr(8cSmqRSY LFG~&k>Fa+0b@c#X literal 0 HcmV?d00001 diff --git a/Tests/images/dilation4.lut b/Tests/images/dilation4.lut new file mode 100644 index 0000000000000000000000000000000000000000..958b801abf8c5a287dd2eb86df082ae05ef7738f GIT binary patch literal 512 jcmZQzU}R(fVsZgUFD3fPwU=7@D0M%j`l;m)a?Jq%?Kc7O literal 0 HcmV?d00001 diff --git a/Tests/images/dilation8.lut b/Tests/images/dilation8.lut new file mode 100644 index 0000000000000000000000000000000000000000..c3bca868404f9b045ce3377574bb094a54546b7c GIT binary patch literal 512 NcmZQz90eme1ONdZ0ssI2 literal 0 HcmV?d00001 diff --git a/Tests/images/edge.lut b/Tests/images/edge.lut new file mode 100644 index 0000000000000000000000000000000000000000..f7aabf41cf7899928ed7d486020c58807ff8ff29 GIT binary patch literal 512 dcmZQzKn09w09BTO0Zp25R30@1hFJJ8008=b0RR91 literal 0 HcmV?d00001 diff --git a/Tests/images/erosion4.lut b/Tests/images/erosion4.lut new file mode 100644 index 0000000000000000000000000000000000000000..9b6d2933e3a4600af7361acc9367ba24eb131f1c GIT binary patch literal 512 ecmZQz7^;Agk%0k($pw_^C)ZwT>7&&B5d8oQH~>$hmBp4oAa_|EwDNh&2kcv6U2@b41JUl@3UvkER d8a1{z3=B$_8QI>o=(&JYd%F6$taD0e0swo&5_0', - '4:(00. 01. ...)->1']) -count,Aout = mop.apply(A) -assert_equal(count,5) -assert_img_equal_img_string(Aout, -""" -....... -....... -..1.1.. -....... -..1.1.. -....... -....... -""") +def test_corner(): + # Create a corner detector pattern + mop = ImageMorph.MorphOp(patterns = ['1:(... ... ...)->0', + '4:(00. 01. ...)->1']) + count,Aout = mop.apply(A) + assert_equal(count,5) + assert_img_equal_img_string(Aout, + """ + ....... + ....... + ..1.1.. + ....... + ..1.1.. + ....... + ....... + """) -# Test the coordinate counting with the same operator -coords = mop.match(A) -assert_equal(len(coords), 4) -assert_equal(tuple(coords), - ((2,2),(4,2),(2,4),(4,4))) -coords = mop.get_on_pixels(Aout) -assert_equal(len(coords), 4) -assert_equal(tuple(coords), - ((2,2),(4,2),(2,4),(4,4))) + # Test the coordinate counting with the same operator + coords = mop.match(A) + assert_equal(len(coords), 4) + assert_equal(tuple(coords), + ((2,2),(4,2),(2,4),(4,4))) + + coords = mop.get_on_pixels(Aout) + assert_equal(len(coords), 4) + assert_equal(tuple(coords), + ((2,2),(4,2),(2,4),(4,4)))