Skip to content

Commit

Permalink
test: check that grey erode and dilate 2d work
Browse files Browse the repository at this point in the history
  • Loading branch information
william-silversmith committed Jun 22, 2024
1 parent 54f7ba8 commit 4dbb50e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions automated_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,19 @@ def test_multilabel_erode_2d():
np.int8,np.int16,np.int32,np.int64,
])
def test_grey_erode(dtype):
labels = np.arange(9, dtype=dtype).reshape((3,3), order="F")
out = fastmorph.erode(labels, mode=fastmorph.Mode.grey)

ans = np.array([
[0, 0, 1],
[0, 0, 1],
[3, 3, 4],
], dtype=dtype).T
assert np.all(out == ans)

out = fastmorph.erode(out, mode=fastmorph.Mode.grey)
assert np.all(out == 0)

labels = np.arange(27, dtype=dtype).reshape((3,3,3), order="F")
out = fastmorph.erode(labels, mode=fastmorph.Mode.grey)

Expand Down Expand Up @@ -254,6 +267,20 @@ def test_grey_dilate(dtype):
L = 5
H = 10

labels = np.zeros((3,3), dtype=dtype)
labels[0,0] = L
labels[2,2] = H

out = fastmorph.dilate(labels, mode=fastmorph.Mode.grey)

ans = np.array([
[L, L, 0],
[L, H, H],
[0, H, H],
], dtype=dtype).T

assert np.all(out == ans)

labels = np.zeros((3,3,3), dtype=dtype)
labels[0,0,0] = L
labels[2,2,2] = H
Expand Down Expand Up @@ -290,4 +317,10 @@ def test_grey_dilate_bool():
out = fastmorph.dilate(labels, mode=fastmorph.Mode.grey)
assert np.all(out == True)

labels = np.zeros((3,3), dtype=bool)
labels[1,1] = True

out = fastmorph.dilate(labels, mode=fastmorph.Mode.grey)
assert np.all(out == True)


0 comments on commit 4dbb50e

Please sign in to comment.