本文整理匯總了Python中nipy.core.api.Image.get_data()[50:55,40:55,30:33]方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.get_data()[50:55,40:55,30:33]方法的具體用法?Python Image.get_data()[50:55,40:55,30:33]怎麽用?Python Image.get_data()[50:55,40:55,30:33]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nipy.core.api.Image
的用法示例。
在下文中一共展示了Image.get_data()[50:55,40:55,30:33]方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_slice_from_3d
# 需要導入模塊: from nipy.core.api import Image [as 別名]
# 或者: from nipy.core.api.Image import get_data()[50:55,40:55,30:33] [as 別名]
def test_slice_from_3d():
# Resample a 3d image, returning a zslice, yslice and xslice
#
# This example creates a coordmap that coincides with
# a given z, y, or x slice of an image, and checks that
# resampling agrees with the data in the given slice.
shape = (100,90,80)
g = AffineTransform.from_params('ijk',
'xyz',
np.diag([0.5,0.5,0.5,1]))
img = Image(np.ones(shape), g)
img.get_data()[50:55,40:55,30:33] = 3
I = np.identity(4)
zsl = slices.zslice(26,
((0,49.5), 100),
((0,44.5), 90),
img.reference)
ir = resample(img, zsl, I, (100, 90))
assert_array_almost_equal(ir.get_data(), img[:,:,53].get_data())
ysl = slices.yslice(22,
((0,49.5), 100),
((0,39.5), 80),
img.reference)
ir = resample(img, ysl, I, (100, 80))
assert_array_almost_equal(ir.get_data(), img[:,45,:].get_data())
xsl = slices.xslice(15.5,
((0,44.5), 90),
((0,39.5), 80),
img.reference)
ir = resample(img, xsl, I, (90, 80))
assert_array_almost_equal(ir.get_data(), img[32,:,:].get_data())
示例2: test_2d_from_3d
# 需要導入模塊: from nipy.core.api import Image [as 別名]
# 或者: from nipy.core.api.Image import get_data()[50:55,40:55,30:33] [as 別名]
def test_2d_from_3d():
# Resample a 3d image on a 2d affine grid
# This example creates a coordmap that coincides with
# the 10th slice of an image, and checks that
# resampling agrees with the data in the 10th slice.
shape = (100,90,80)
g = AffineTransform.from_params('ijk', 'xyz', np.diag([0.5,0.5,0.5,1]))
i = Image(np.ones(shape), g)
i.get_data()[50:55,40:55,30:33] = 3.
a = np.identity(4)
g2 = ArrayCoordMap.from_shape(g, shape)[10]
ir = resample(i, g2.coordmap, a, g2.shape)
assert_array_almost_equal(ir.get_data(), i[10].get_data())
示例3: test_rotate3d
# 需要導入模塊: from nipy.core.api import Image [as 別名]
# 或者: from nipy.core.api.Image import get_data()[50:55,40:55,30:33] [as 別名]
def test_rotate3d():
# Rotate / transpose a 3d image on a non-square grid
g = AffineTransform.from_params('ijk', 'xyz', np.diag([0.5,0.6,0.7,1]))
g2 = AffineTransform.from_params('ijk', 'xyz', np.diag([0.5,0.7,0.6,1]))
shape = (100,90,80)
i = Image(np.ones(shape), g)
i.get_data()[50:55,40:55,30:33] = 3.
a = np.array([[1,0,0,0],
[0,0,1,0],
[0,1,0,0],
[0,0,0,1.]])
ir = resample(i, g2, a, (100,80,90))
assert_array_almost_equal(np.transpose(ir.get_data(), (0,2,1)),
i.get_data())
示例4: test_resample3d
# 需要導入模塊: from nipy.core.api import Image [as 別名]
# 或者: from nipy.core.api.Image import get_data()[50:55,40:55,30:33] [as 別名]
def test_resample3d():
g = AffineTransform.from_params('ijk', 'xyz', np.diag([0.5,0.5,0.5,1]))
shape = (100,90,80)
i = Image(np.ones(shape), g)
i.get_data()[50:55,40:55,30:33] = 3.
# This mapping describes a mapping from the "target" physical
# coordinates to the "image" physical coordinates. The 4x4 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 [-6,-8,-10] voxels towards the origin
a = np.identity(4)
a[:3,-1] = [3,4,5]
ir = resample(i, i.coordmap, a, (100,90,80))
assert_array_almost_equal(ir.get_data()[44:49,32:47,20:23], 3.)