예제 #1
0
def test_3d_fallback_black_tophat():
    image = np.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 = gray.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=np.uint8),
                                          footprint=footprint)
    assert_array_equal(new_image, image_expected)
예제 #2
0
 def test_black_tophat_white_pixel(self):
     for s in self.footprints:
         tophat = gray.black_tophat(self.white_pixel, s)
         assert np.all(tophat == 0)
예제 #3
0
 def test_black_tophat_black_pixel(self):
     for s in self.footprints:
         tophat = gray.black_tophat(self.black_pixel, s)
         assert np.all(tophat == (255 - self.black_pixel))