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


Python Image.get_data()[50:55,40:55]方法代码示例

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


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

示例1: test_nonaffine

# 需要导入模块: from nipy.core.api import Image [as 别名]
# 或者: from nipy.core.api.Image import get_data()[50:55,40:55] [as 别名]
def test_nonaffine():
    # resamples an image along a curve through the image.
    #
    # FIXME: use the reference.evaluate.Grid to perform this nicer
    # FIXME: Remove pylab references
    def curve(x): # function accept N by 1, returns N by 2 
        return (np.vstack([5*np.sin(x.T),5*np.cos(x.T)]).T + [52,47])
    for names in (('xy', 'ij', 't', 'u'),('ij', 'xy', 't', 's')):
        in_names, out_names, tin_names, tout_names = names
        g = AffineTransform.from_params(in_names, out_names, np.identity(3))
        img = Image(np.ones((100,90)), g)
        img.get_data()[50:55,40:55] = 3.
        tcoordmap = AffineTransform.from_start_step(
            tin_names,
            tout_names,
            [0],
            [np.pi*1.8/100])
        ir = resample(img, tcoordmap, curve, (100,))
    if gui_review:
        import pylab
        pylab.figure(num=3)
        pylab.imshow(img, interpolation='nearest')
        d = curve(np.linspace(0,1.8*np.pi,100))
        pylab.plot(d[0], d[1])
        pylab.gca().set_ylim([0,99])
        pylab.gca().set_xlim([0,89])
        pylab.figure(num=4)
        pylab.plot(ir.get_data())
开发者ID:Naereen,项目名称:nipy,代码行数:30,代码来源:test_resample.py

示例2: test_resample2d3

# 需要导入模块: from nipy.core.api import Image [as 别名]
# 或者: from nipy.core.api.Image import get_data()[50:55,40:55] [as 别名]
def test_resample2d3():
    # Same as test_resample2d, only a different way of specifying
    # the transform: here it is an (A,b) pair
    g = AffineTransform.from_params('ij', 'xy', np.diag([0.5,0.5,1]))
    i = Image(np.ones((100,90)), g)
    i.get_data()[50:55,40:55] = 3.
    a = np.identity(3)
    a[:2,-1] = 4.
    ir = resample(i, i.coordmap, a, (100,90))
    assert_array_almost_equal(ir.get_data()[42:47,32:47], 3.)
开发者ID:Naereen,项目名称:nipy,代码行数:12,代码来源:test_resample.py

示例3: test_resample2d2

# 需要导入模块: from nipy.core.api import Image [as 别名]
# 或者: from nipy.core.api.Image import get_data()[50:55,40:55] [as 别名]
def test_resample2d2():
    g = AffineTransform.from_params('ij', 'xy', np.diag([0.5,0.5,1]))
    i = Image(np.ones((100,90)), g)
    i.get_data()[50:55,40:55] = 3.
    a = np.identity(3)
    a[:2,-1] = 4.
    A = np.identity(2)
    b = np.ones(2)*4
    ir = resample(i, i.coordmap, (A, b), (100,90))
    assert_array_almost_equal(ir.get_data()[42:47,32:47], 3.)
开发者ID:Naereen,项目名称:nipy,代码行数:12,代码来源:test_resample.py

示例4: test_rotate2d

# 需要导入模块: from nipy.core.api import Image [as 别名]
# 或者: from nipy.core.api.Image import get_data()[50:55,40:55] [as 别名]
def test_rotate2d():
    # Rotate an image in 2d on a square grid, should result in transposed image
    g = AffineTransform.from_params('ij', 'xy', np.diag([0.7,0.5,1]))
    g2 = AffineTransform.from_params('ij', 'xy', np.diag([0.5,0.7,1]))
    i = Image(np.ones((100,100)), g)
    # This sets the image data by writing into the array
    i.get_data()[50:55,40:55] = 3.
    a = np.array([[0,1,0],
                  [1,0,0],
                  [0,0,1]], np.float)
    ir = resample(i, g2, a, (100, 100))
    assert_array_almost_equal(ir.get_data().T, i.get_data())
开发者ID:Naereen,项目名称:nipy,代码行数:14,代码来源:test_resample.py

示例5: test_resample2d1

# 需要导入模块: from nipy.core.api import Image [as 别名]
# 或者: from nipy.core.api.Image import get_data()[50:55,40:55] [as 别名]
def test_resample2d1():
    # Tests the same as test_resample2d, only using a callable instead of
    # an AffineTransform instance
    g = AffineTransform.from_params('ij', 'xy', np.diag([0.5,0.5,1]))
    i = Image(np.ones((100,90)), g)
    i.get_data()[50:55,40:55] = 3.
    a = np.identity(3)
    a[:2,-1] = 4.
    A = np.identity(2)
    b = np.ones(2)*4
    def mapper(x):
        return np.dot(x, A.T) + b
    ir = resample(i, i.coordmap, mapper, (100,90))
    assert_array_almost_equal(ir.get_data()[42:47,32:47], 3.)
开发者ID:Naereen,项目名称:nipy,代码行数:16,代码来源:test_resample.py

示例6: test_resample2d

# 需要导入模块: from nipy.core.api import Image [as 别名]
# 或者: from nipy.core.api.Image import get_data()[50:55,40:55] [as 别名]
def test_resample2d():
    g = AffineTransform.from_params('ij', 'xy', np.diag([0.5,0.5,1]))
    i = Image(np.ones((100,90)), g)
    i.get_data()[50:55,40:55] = 3.
    # This mapping describes a mapping from the "target" physical
    # coordinates to the "image" physical coordinates.  The 3x3 matrix
    # below indicates that the "target" physical coordinates are related
    # to the "image" physical coordinates by a shift of -4 in each
    # coordinate.  Or, to find the "image" physical coordinates, given
    # the "target" physical coordinates, we add 4 to each "target
    # coordinate".  The resulting resampled image should show the
    # overall image shifted -8,-8 voxels towards the origin
    a = np.identity(3)
    a[:2,-1] = 4.
    ir = resample(i, i.coordmap, a, (100,90))
    assert_array_almost_equal(ir.get_data()[42:47,32:47], 3.)
开发者ID:Naereen,项目名称:nipy,代码行数:18,代码来源:test_resample.py

示例7: test_rotate2d3

# 需要导入模块: from nipy.core.api import Image [as 别名]
# 或者: from nipy.core.api.Image import get_data()[50:55,40:55] [as 别名]
def test_rotate2d3():
    # Another way to rotate/transpose the image, similar to
    # test_rotate2d2 and test_rotate2d, except the world of the
    # output coordmap is the same as the world of the
    # original image. That is, the data is transposed on disk, but the
    # output coordinates are still 'x,'y' order, not 'y', 'x' order as
    # above

    # this functionality may or may not be used a lot. if data is to
    # be transposed but one wanted to keep the NIFTI order of output
    # coords this would do the trick
    g = AffineTransform.from_params('xy', 'ij', np.diag([0.5,0.7,1]))
    i = Image(np.ones((100,80)), g)
    # This sets the image data by writing into the array
    i.get_data()[50:55,40:55] = 3.
    a = np.identity(3)
    g2 = AffineTransform.from_params('xy', 'ij', np.array([[0,0.5,0],
                                                  [0.7,0,0],
                                                  [0,0,1]]))
    ir = resample(i, g2, a, (80,100))
    assert_array_almost_equal(ir.get_data().T, i.get_data())
开发者ID:Naereen,项目名称:nipy,代码行数:23,代码来源:test_resample.py


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