def setUp(self): self.black_pixel = 255 * np.ones((4, 4), dtype=np.uint8) self.black_pixel[1, 1] = 0 self.white_pixel = 255 - self.black_pixel self.footprints = [ footprints.square(2), footprints.rectangle(2, 2), footprints.rectangle(2, 1), footprints.rectangle(1, 2) ]
def test_rectangle_decomposition(function, nrows, ncols, decomposition): """Validate footprint decomposition for various shapes. comparison is made to the case without decomposition. """ footprint_ndarray = footprints.rectangle(nrows, ncols, decomposition=None) footprint = footprints.rectangle(nrows, ncols, decomposition=decomposition) img = _get_decomp_test_data(function) func = getattr(binary, function) expected = func(img, footprint=footprint_ndarray) out = func(img, footprint=footprint) assert_array_equal(expected, out)
def test_rectangle_footprint(self): """Test rectangle footprints""" for i in range(0, 5): for j in range(0, 5): actual_mask = footprints.rectangle(i, j) expected_mask = np.ones((i, j), dtype='uint8') assert_equal(expected_mask, actual_mask)