def test_population(): # check the number of valid pixels in the neighborhood image = np.zeros((5, 5), dtype=np.uint8) elem = np.ones((3, 3), dtype=np.uint8) out = np.empty_like(image) mask = np.ones(image.shape, dtype=np.uint8) rank.pop(image=image, selem=elem, out=out, mask=mask) r = np.array([[4, 6, 6, 6, 4], [6, 9, 9, 9, 6], [6, 9, 9, 9, 6], [6, 9, 9, 9, 6], [4, 6, 6, 6, 4]]) assert_array_equal(r, out)