當前位置: 首頁>>代碼示例>>Python>>正文


Python ndimage.grey_dilation方法代碼示例

本文整理匯總了Python中scipy.ndimage.grey_dilation方法的典型用法代碼示例。如果您正苦於以下問題:Python ndimage.grey_dilation方法的具體用法?Python ndimage.grey_dilation怎麽用?Python ndimage.grey_dilation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy.ndimage的用法示例。


在下文中一共展示了ndimage.grey_dilation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: damage_mask

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def damage_mask(mask, scale_factor, shift_absolute, shift_factor):
  assert not (shift_absolute != 0.0 and shift_factor != 0.0)
  mask = mask.astype("float32")

  if shift_absolute != 0.0:
    mask = shift_mask_speed_absolute(mask, max_speed=shift_absolute)
  elif shift_factor != 0.0:
    mask = shift_mask_speed_factor(mask, factor=shift_factor)

  if scale_factor != 0.0:
    scale = numpy.random.uniform(1 - scale_factor, 1 + scale_factor)
    mask = scale_mask(mask, scale)

  # dilation_size = 5
  # mask = grey_dilation(mask, size=(dilation_size, dilation_size, 1))
  return mask 
開發者ID:JonathonLuiten,項目名稱:PReMVOS,代碼行數:18,代碼來源:MaskDamager.py

示例2: generate_weight_map

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def generate_weight_map(weight_map,heatmap):

    k_size = 3
    dilate = ndimage.grey_dilation(heatmap ,size=(k_size,k_size))
    weight_map[np.where(dilate>0.2)] = 1
    return weight_map 
開發者ID:protossw512,項目名稱:AdaptiveWingLoss,代碼行數:8,代碼來源:utils.py

示例3: get_skeleton

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def get_skeleton(self):
        return ndi.grey_dilation(self.img_skl, size=2) 
開發者ID:OnionDoctor,項目名稱:FCN_for_crack_recognition,代碼行數:4,代碼來源:FCN_CrackAnalysis.py

示例4: test_grey_dilation01

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_grey_dilation01(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[0, 1, 1], [1, 0, 1]]
        output = ndimage.grey_dilation(array,
                                                 footprint=footprint)
        assert_array_almost_equal([[7, 7, 9, 9, 5],
                              [7, 9, 8, 9, 7],
                              [8, 8, 8, 7, 7]], output) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:12,代碼來源:test_ndimage.py

示例5: test_grey_dilation02

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_grey_dilation02(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[0, 1, 1], [1, 0, 1]]
        structure = [[0, 0, 0], [0, 0, 0]]
        output = ndimage.grey_dilation(array,
                             footprint=footprint, structure=structure)
        assert_array_almost_equal([[7, 7, 9, 9, 5],
                              [7, 9, 8, 9, 7],
                              [8, 8, 8, 7, 7]], output) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:13,代碼來源:test_ndimage.py

示例6: test_grey_dilation03

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_grey_dilation03(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[0, 1, 1], [1, 0, 1]]
        structure = [[1, 1, 1], [1, 1, 1]]
        output = ndimage.grey_dilation(array,
                             footprint=footprint, structure=structure)
        assert_array_almost_equal([[8, 8, 10, 10, 6],
                              [8, 10, 9, 10, 8],
                              [9, 9, 9, 8, 8]], output) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:13,代碼來源:test_ndimage.py

示例7: test_grey_opening01

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_grey_opening01(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[1, 0, 1], [1, 1, 0]]
        tmp = ndimage.grey_erosion(array, footprint=footprint)
        expected = ndimage.grey_dilation(tmp, footprint=footprint)
        output = ndimage.grey_opening(array,
                                                footprint=footprint)
        assert_array_almost_equal(expected, output) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:12,代碼來源:test_ndimage.py

示例8: test_grey_opening02

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_grey_opening02(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[1, 0, 1], [1, 1, 0]]
        structure = [[0, 0, 0], [0, 0, 0]]
        tmp = ndimage.grey_erosion(array, footprint=footprint,
                                             structure=structure)
        expected = ndimage.grey_dilation(tmp, footprint=footprint,
                                               structure=structure)
        output = ndimage.grey_opening(array,
                             footprint=footprint, structure=structure)
        assert_array_almost_equal(expected, output) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:15,代碼來源:test_ndimage.py

示例9: test_grey_closing02

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_grey_closing02(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[1, 0, 1], [1, 1, 0]]
        structure = [[0, 0, 0], [0, 0, 0]]
        tmp = ndimage.grey_dilation(array, footprint=footprint,
                                              structure=structure)
        expected = ndimage.grey_erosion(tmp, footprint=footprint,
                                              structure=structure)
        output = ndimage.grey_closing(array,
                              footprint=footprint, structure=structure)
        assert_array_almost_equal(expected, output) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:15,代碼來源:test_ndimage.py

示例10: test_morphological_gradient01

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_morphological_gradient01(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[1, 0, 1], [1, 1, 0]]
        structure = [[0, 0, 0], [0, 0, 0]]
        tmp1 = ndimage.grey_dilation(array,
                             footprint=footprint, structure=structure)
        tmp2 = ndimage.grey_erosion(array, footprint=footprint,
                                              structure=structure)
        expected = tmp1 - tmp2
        output = numpy.zeros(array.shape, array.dtype)
        ndimage.morphological_gradient(array,
                footprint=footprint, structure=structure, output=output)
        assert_array_almost_equal(expected, output) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:17,代碼來源:test_ndimage.py

示例11: test_morphological_gradient02

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_morphological_gradient02(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[1, 0, 1], [1, 1, 0]]
        structure = [[0, 0, 0], [0, 0, 0]]
        tmp1 = ndimage.grey_dilation(array,
                             footprint=footprint, structure=structure)
        tmp2 = ndimage.grey_erosion(array, footprint=footprint,
                                              structure=structure)
        expected = tmp1 - tmp2
        output = ndimage.morphological_gradient(array,
                                footprint=footprint, structure=structure)
        assert_array_almost_equal(expected, output) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:16,代碼來源:test_ndimage.py

示例12: test_morphological_laplace01

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_morphological_laplace01(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[1, 0, 1], [1, 1, 0]]
        structure = [[0, 0, 0], [0, 0, 0]]
        tmp1 = ndimage.grey_dilation(array,
                              footprint=footprint, structure=structure)
        tmp2 = ndimage.grey_erosion(array, footprint=footprint,
                                              structure=structure)
        expected = tmp1 + tmp2 - 2 * array
        output = numpy.zeros(array.shape, array.dtype)
        ndimage.morphological_laplace(array, footprint=footprint,
                                     structure=structure, output=output)
        assert_array_almost_equal(expected, output) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:17,代碼來源:test_ndimage.py

示例13: test_morphological_laplace02

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_morphological_laplace02(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[1, 0, 1], [1, 1, 0]]
        structure = [[0, 0, 0], [0, 0, 0]]
        tmp1 = ndimage.grey_dilation(array,
                             footprint=footprint, structure=structure)
        tmp2 = ndimage.grey_erosion(array, footprint=footprint,
                                              structure=structure)
        expected = tmp1 + tmp2 - 2 * array
        output = ndimage.morphological_laplace(array,
                                footprint=footprint, structure=structure)
        assert_array_almost_equal(expected, output) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:16,代碼來源:test_ndimage.py

示例14: test_dilation_scalar_size

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_dilation_scalar_size(self):
        result = ndimage.grey_dilation(self.array, size=3)
        assert_array_almost_equal(result, self.dilated3x3) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:5,代碼來源:test_ndimage.py

示例15: test_grey_dilation01

# 需要導入模塊: from scipy import ndimage [as 別名]
# 或者: from scipy.ndimage import grey_dilation [as 別名]
def test_grey_dilation01(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                             [7, 6, 9, 3, 5],
                             [5, 8, 3, 7, 1]])
        footprint = [[0, 1, 1], [1, 0, 1]]
        output = ndimage.grey_dilation(array, footprint=footprint)
        assert_array_almost_equal([[7, 7, 9, 9, 5],
                                   [7, 9, 8, 9, 7],
                                   [8, 8, 8, 7, 7]], output) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:11,代碼來源:test_ndimage.py


注:本文中的scipy.ndimage.grey_dilation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。