def TF_zoom(x, scale=1.0, target=None):
assert len(x.shape) == 3
h, w, nc = x.shape
assert h == w
# Zoom
xc = rescale(x, scale)
diff = h - xc.shape[0]
d = int(np.floor(diff / 2.0))
if d >= 0:
padding = ((d, d),(d, d),(0,0))
if diff % 2 != 0:
padding = ((d,d+1), (d,d + 1),(0,0))
return np.pad(xc, padding, mode='edge')
else:
return xc[-d:h-d, -d:w-d].reshape(h, w, nc)
评论列表
文章目录