本文整理汇总了Python中scipy.ndimage.interpolation.zoom方法的典型用法代码示例。如果您正苦于以下问题:Python interpolation.zoom方法的具体用法?Python interpolation.zoom怎么用?Python interpolation.zoom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块scipy.ndimage.interpolation的用法示例。
在下文中一共展示了interpolation.zoom方法的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: resample
点赞 6
# 需要导入模块: from scipy.ndimage import interpolation [as 别名]
# 或者: from scipy.ndimage.interpolation import zoom [as 别名]
def resample(imgs, spacing, new_spacing,order=2):
if len(imgs.shape)==3:
new_shape = np.round(imgs.shape * spacing / new_spacing)
true_spacing = spacing * imgs.shape / new_shape
resize_factor = new_shape / imgs.shape
imgs = zoom(imgs, resize_factor, mode = 'nearest',order=order)
return imgs, true_spacing
elif len(imgs.shape)==4:
n = imgs.shape[-1]
newimg = []
for i in range(n):
slice = imgs[:,:,:,i]
newslice,true_spacing = resample(slice,spacing,new_spacing)
newimg.append(newslice)
newimg=np.transpose(np.array(newimg),[1,2,3,0])
return newimg,true_spacing
else:
raise ValueError('wrong shape')
开发者ID:uci-cbcl,项目名称:DeepLung,代码行数:20,
示例2: get_aligned_face
点赞 6
# 需要导入模块: from scipy.ndimage import interpolation [as 别名]
# 或者: from scipy.ndimage.interpolation import zoom [as 别名]
def get_aligned_face(self, i, l_factor = 1.3):
'''
The second core function that converts the data from self.coordinates into an face image.
'''
frame = self.get(i)
if i in self.coordinates:
c, l, r = self.coordinates[i]
l = int(l) * l_factor # fine-tuning the face zoom we really want
dl_ = floor(np.sqrt(2) * l / 2) # largest zone even when rotated
patch = self.get_image_slice(frame,
floor(c[0] - dl_),
floor(c[0] + dl_),
floor(c[1] - dl_),
floor(c[1] + dl_))
rotated_patch = rotate(patch, -r, reshape=False)
# note : dl_ is the center of the patch of length 2dl_
return self.get_image_slice(rotated_patch,
floor(dl_-l//2),
floor(dl_+l//2),
floor(dl_-l//2),
floor(dl_+l//2))
return frame
## Face prediction
开发者ID:DariusAf,项目名称:MesoNet,代码行数:27,
示例3: fluo_AG_D
点赞 6
# 需要导入模块: from scipy.ndimage import interpolation [as 别名]
# 或者: from scipy.ndimage.interpolation import zoom [as 别名]
def fluo_AG_D(x, scale=4, upsample=False):
xn = np.array(x)
xorig_max = xn.max()
xn = xn.astype(np.float32)
xn /= float(np.iinfo(np.uint8).max)
lvar = filters.gaussian(xn, sigma=5) + 1e-10
xn = random_noise(xn, mode='localvar', local_vars=lvar*0.5)
new_max = xn.max()
x = xn
if new_max > 0:
xn /= new_max
xn *= xorig_max
x_down = npzoom(x, 1/scale, order=1)
#x_up = npzoom(x_down, scale, order=1)
return PIL.Image.fromarray(x_down.astype(np.uint8))
开发者ID:BPHO-Salk,项目名称:PSSR,代码行数:18,
示例4: fluo_SP_AG_D_sameas_preprint
点赞 6
# 需要导入模块: from scipy.ndimage import interpolation [as 别名]
# 或者: from scipy.ndimage.interpolation import zoom [as 别名]
def fluo_SP_AG_D_sameas_preprint(x, scale=4, upsample=False):
xn = np.array(x)
xorig_max = xn.max()
xn = xn.astype(np.float32)
xn /= float(np.iinfo(np.uint8).max)
xn = random_noise(xn, mode='salt', amount=0.005)
xn = random_noise(xn, mode='pepper', amount=0.005)
lvar = filters.gaussian(xn, sigma=5) + 1e-10
xn = random_noise(xn, mode='localva