def test_selem_overflow(): strel = np.ones((17, 17), dtype=np.uint8) img = np.zeros((20, 20), dtype=bool) img[2:19, 2:19] = True binary_res = binary.binary_erosion(img, strel) gray_res = img_as_bool(gray.erosion(img, strel)) testing.assert_array_equal(binary_res, gray_res)
def test_selem_overflow(): strel = np.ones((17, 17), dtype=np.uint8) img = np.zeros((20, 20), dtype=bool) img[2:19, 2:19] = True binary_res = binary.binary_erosion(img, strel) grey_res = img_as_bool(grey.erosion(img, strel)) testing.assert_array_equal(binary_res, grey_res)
def test_footprint_overflow(): footprint = np.ones((17, 17), dtype=np.uint8) img = np.zeros((20, 20), dtype=bool) img[2:19, 2:19] = True binary_res = binary.binary_erosion(img, footprint) gray_res = img_as_bool(gray.erosion(img, footprint)) assert_array_equal(binary_res, gray_res)
def test_selem_overflow(): strel = np.ones((17, 17), dtype=np.uint8) img = np.zeros((20, 20)) img[2:19, 2:19] = 1 binary_res = binary.binary_erosion(img, strel) with expected_warnings(['precision loss']): grey_res = img_as_bool(grey.erosion(img, strel)) testing.assert_array_equal(binary_res, grey_res)
def mark_areas(image: np.ndarray) -> Tuple[np.ndarray, int]: """ Method to segment clustered areas :param image: The image to segment :return: The segmented area """ # Define mask mask = create_circular_mask(40, 40) # Fill image fill = binary_fill_holes(image) # Perform binary erosion on image er = binary_erosion(fill, selem=mask) # Label eroded map lab, nums = label(er) # Dilate eroded map lab = dilation(lab, selem=mask) return lab, nums
def test_binary_erosion(): strel = selem.square(3) binary_res = binary.binary_erosion(bw_img, strel) grey_res = img_as_bool(grey.erosion(bw_img, strel)) testing.assert_array_equal(binary_res, grey_res)
def test_non_square_image(): strel = selem.square(3) binary_res = binary.binary_erosion(bw_img[:100, :200], strel) grey_res = img_as_bool(grey.erosion(bw_img[:100, :200], strel)) testing.assert_array_equal(binary_res, grey_res)
def test_binary_erosion(): strel = selem.square(3) binary_res = binary.binary_erosion(bw_img, strel) gray_res = img_as_bool(gray.erosion(bw_img, strel)) testing.assert_array_equal(binary_res, gray_res)
def test_non_square_image(): strel = selem.square(3) binary_res = binary.binary_erosion(bw_img[:100, :200], strel) gray_res = img_as_bool(gray.erosion(bw_img[:100, :200], strel)) testing.assert_array_equal(binary_res, gray_res)
def test_binary_erosion(): footprint = morphology.square(3) binary_res = binary.binary_erosion(bw_img, footprint) gray_res = img_as_bool(gray.erosion(bw_img, footprint)) assert_array_equal(binary_res, gray_res)
def test_non_square_image(): footprint = morphology.square(3) binary_res = binary.binary_erosion(bw_img[:100, :200], footprint) gray_res = img_as_bool(gray.erosion(bw_img[:100, :200], footprint)) assert_array_equal(binary_res, gray_res)
def test_binary_erosion(): strel = selem.square(3) binary_res = binary.binary_erosion(bw_img, strel) with expected_warnings(['precision loss']): grey_res = img_as_bool(grey.erosion(bw_img, strel)) testing.assert_array_equal(binary_res, grey_res)
def test_binary_erosion(): strel = selem.square(3) binary_res = binary.binary_erosion(bw_lena, strel) grey_res = grey.erosion(bw_lena, strel) testing.assert_array_equal(binary_res, grey_res)