python interpolation函数_Python interpolation.zoom方法代码示例

本文详细介绍了Python库scipy.ndimage.interpolation中的zoom方法,包括其用途、参数和典型应用场景。通过20个精选代码示例,展示了在图像处理和数据缩放中的应用,如图像重采样、图像调整大小和数据处理等。
摘要由CSDN通过智能技术生成

本文整理汇总了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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值