当前位置: 首页>>代码示例>>Python>>正文


Python ndimage.laplace方法代码示例

本文整理汇总了Python中scipy.ndimage.laplace方法的典型用法代码示例。如果您正苦于以下问题:Python ndimage.laplace方法的具体用法?Python ndimage.laplace怎么用?Python ndimage.laplace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.ndimage的用法示例。


在下文中一共展示了ndimage.laplace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_laplace01

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import laplace [as 别名]
def test_laplace01(self):
        for type in [numpy.int32, numpy.float32, numpy.float64]:
            array = numpy.array([[3, 2, 5, 1, 4],
                                    [5, 8, 3, 7, 1],
                                    [5, 6, 9, 3, 5]], type) * 100
            tmp1 = ndimage.correlate1d(array, [1, -2, 1], 0)
            tmp2 = ndimage.correlate1d(array, [1, -2, 1], 1)
            output = ndimage.laplace(array)
            assert_array_almost_equal(tmp1 + tmp2, output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:11,代码来源:test_ndimage.py

示例2: test_laplace02

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import laplace [as 别名]
def test_laplace02(self):
        for type in [numpy.int32, numpy.float32, numpy.float64]:
            array = numpy.array([[3, 2, 5, 1, 4],
                                    [5, 8, 3, 7, 1],
                                    [5, 6, 9, 3, 5]], type) * 100
            tmp1 = ndimage.correlate1d(array, [1, -2, 1], 0)
            tmp2 = ndimage.correlate1d(array, [1, -2, 1], 1)
            output = numpy.zeros(array.shape, type)
            ndimage.laplace(array, output=output)
            assert_array_almost_equal(tmp1 + tmp2, output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:test_ndimage.py

示例3: test_laplace01

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import laplace [as 别名]
def test_laplace01(self):
        for type_ in [numpy.int32, numpy.float32, numpy.float64]:
            array = numpy.array([[3, 2, 5, 1, 4],
                                 [5, 8, 3, 7, 1],
                                 [5, 6, 9, 3, 5]], type_) * 100
            tmp1 = ndimage.correlate1d(array, [1, -2, 1], 0)
            tmp2 = ndimage.correlate1d(array, [1, -2, 1], 1)
            output = ndimage.laplace(array)
            assert_array_almost_equal(tmp1 + tmp2, output) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:11,代码来源:test_ndimage.py

示例4: test_laplace02

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import laplace [as 别名]
def test_laplace02(self):
        for type_ in [numpy.int32, numpy.float32, numpy.float64]:
            array = numpy.array([[3, 2, 5, 1, 4],
                                 [5, 8, 3, 7, 1],
                                 [5, 6, 9, 3, 5]], type_) * 100
            tmp1 = ndimage.correlate1d(array, [1, -2, 1], 0)
            tmp2 = ndimage.correlate1d(array, [1, -2, 1], 1)
            output = numpy.zeros(array.shape, type_)
            ndimage.laplace(array, output=output)
            assert_array_almost_equal(tmp1 + tmp2, output) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:12,代码来源:test_ndimage.py

示例5: test_multiple_modes

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import laplace [as 别名]
def test_multiple_modes():
    # Test that the filters with multiple mode cababilities for different
    # dimensions give the same result as applying a single mode.
    arr = np.array([[1., 0., 0.],
                    [1., 1., 0.],
                    [0., 0., 0.]])

    mode1 = 'reflect'
    mode2 = ['reflect', 'reflect']

    assert_equal(sndi.gaussian_filter(arr, 1, mode=mode1),
                 sndi.gaussian_filter(arr, 1, mode=mode2))
    assert_equal(sndi.prewitt(arr, mode=mode1),
                 sndi.prewitt(arr, mode=mode2))
    assert_equal(sndi.sobel(arr, mode=mode1),
                 sndi.sobel(arr, mode=mode2))
    assert_equal(sndi.laplace(arr, mode=mode1),
                 sndi.laplace(arr, mode=mode2))
    assert_equal(sndi.gaussian_laplace(arr, 1, mode=mode1),
                 sndi.gaussian_laplace(arr, 1, mode=mode2))
    assert_equal(sndi.maximum_filter(arr, size=5, mode=mode1),
                 sndi.maximum_filter(arr, size=5, mode=mode2))
    assert_equal(sndi.minimum_filter(arr, size=5, mode=mode1),
                 sndi.minimum_filter(arr, size=5, mode=mode2))
    assert_equal(sndi.gaussian_gradient_magnitude(arr, 1, mode=mode1),
                 sndi.gaussian_gradient_magnitude(arr, 1, mode=mode2))
    assert_equal(sndi.uniform_filter(arr, 5, mode=mode1),
                 sndi.uniform_filter(arr, 5, mode=mode2)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:30,代码来源:test_filters.py

示例6: test_multiple_modes_laplace

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import laplace [as 别名]
def test_multiple_modes_laplace():
    # Test laplace filter for multiple extrapolation modes
    arr = np.array([[1., 0., 0.],
                    [1., 1., 0.],
                    [0., 0., 0.]])

    expected = np.array([[-2., 2., 1.],
                         [-2., -3., 2.],
                         [1., 1., 0.]])

    modes = ['reflect', 'wrap']

    assert_equal(expected,
                 sndi.laplace(arr, mode=modes)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:16,代码来源:test_filters.py

示例7: plot_tree

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import laplace [as 别名]
def plot_tree(max_depth=1):
    fig, ax = plt.subplots(1, 2, figsize=(15, 7))
    h = 0.02

    x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
    y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
    xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))

    if max_depth != 0:
        tree = DecisionTreeClassifier(max_depth=max_depth, random_state=1).fit(X, y)
        Z = tree.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]
        Z = Z.reshape(xx.shape)
        faces = tree.tree_.apply(np.c_[xx.ravel(), yy.ravel()].astype(np.float32))
        faces = faces.reshape(xx.shape)
        border = ndimage.laplace(faces) != 0
        ax[0].contourf(xx, yy, Z, alpha=.4)
        ax[0].scatter(xx[border], yy[border], marker='.', s=1)
        ax[0].set_title("max_depth = %d" % max_depth)
        ax[1].imshow(tree_image(tree))
        ax[1].axis("off")
    else:
        ax[0].set_title("data set")
        ax[1].set_visible(False)
    ax[0].scatter(X[:, 0], X[:, 1], c=np.array(['b', 'r'])[y], s=60)
    ax[0].set_xlim(x_min, x_max)
    ax[0].set_ylim(y_min, y_max)
    ax[0].set_xticks(())
    ax[0].set_yticks(()) 
开发者ID:amueller,项目名称:scipy_2015_sklearn_tutorial,代码行数:30,代码来源:plot_interactive_tree.py

示例8: __init__

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import laplace [as 别名]
def __init__(self, upsample_factor=1, max_displacement=None,
                 num_images_for_mean=100,
                 randomise_frames=True, err_thresh=0.01, max_iterations=5,
                 rotation_scaling=False, save_fmt='mptiff', save_name=None,
                 n_processes=1, verbose=False, return_registered=False,
                 laplace=0.0):
        self._params = dict(locals())
        del self._params['self'] 
开发者ID:losonczylab,项目名称:sima,代码行数:10,代码来源:dftreg.py

示例9: run_FreeCAD_ImageT

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import laplace [as 别名]
def run_FreeCAD_ImageT(self):

    from scipy import ndimage
    fn=self.getData('image')
    import matplotlib.image as mpimg    

    img=mpimg.imread(fn)
    (sa,sb,sc)=img.shape
    red=0.005*(self.getData("red")+100)
    green=0.005*(self.getData("green")+100)
    blue=0.005*(self.getData("blue")+100)
    #blue=0
    say("rgb",red,green,blue)
    
    
    # andere filtre
    #img = ndimage.sobel(img)
    #img = ndimage.laplace(img)
    
    im2=img[:,:,0]*red+img[:,:,1]*green+img[:,:,2]*blue
    im2=np.round(im2)
    
    if self.getData('invert'):
        im2 = 1- im2
    
    #im2 = ndimage.sobel(im2)

   
    ss=int((self.getData('maskSize')+100)/20)
    say("ss",ss)
    if ss != 0:
        mode=self.getData('mode')
        say("mode",mode)
        if mode=='closing':
            im2=ndimage.grey_closing(im2, size=(ss,ss))
        elif mode=='opening':
            im2=ndimage.grey_opening(im2, size=(ss,ss))    
        elif mode=='erosion':
            im2=ndimage.grey_erosion(im2, size=(ss,ss))
        elif mode=='dilitation':
            im2=ndimage.grey_dilation(im2, footprint=np.ones((ss,ss)))
        else:
            say("NO MODE")
       


    




    nonzes=np.where(im2 == 0)
    pts = [FreeCAD.Vector(sb+-x,sa-y) for y,x in np.array(nonzes).swapaxes(0,1)]
    
    h=10
    pts = [FreeCAD.Vector(sb+-x,sa-y,(red*img[y,x,0]+green*img[y,x,1]+blue*img[y,x,2])*h) for y,x in np.array(nonzes).swapaxes(0,1)]
    colors=[img[y,x] for y,x in np.array(nonzes).swapaxes(0,1)]
    say("len pts",len(pts))
    self.setData("Points_out",pts) 
开发者ID:microelly2,项目名称:NodeEditor,代码行数:61,代码来源:dev_Image.py


注:本文中的scipy.ndimage.laplace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。