def test_3d_fallback_black_tophat(): image = cp.ones((7, 7, 7), dtype=bool) image[2, 2:4, 2:4] = 0 image[3, 2:5, 2:5] = 0 image[4, 3:5, 3:5] = 0 with expected_warnings([r"operator.*deprecated|\A\Z"]): new_image = grey.black_tophat(image) footprint = ndi.generate_binary_structure(3, 1) with expected_warnings([r"operator.*deprecated|\A\Z"]): image_expected = ndi.black_tophat(image.view(dtype=cp.uint8), footprint=footprint) cp.testing.assert_array_equal(new_image, image_expected)
def test_black_tophat_white_pixel(self): for s in self.selems: tophat = grey.black_tophat(self.white_pixel, s) assert cp.all(tophat == 0)
def test_black_tophat_black_pixel(self): for s in self.selems: tophat = grey.black_tophat(self.black_pixel, s) cp.testing.assert_array_equal(tophat, 255 - self.black_pixel)