def sresample(src, outshape):
""" Simple 3d array resampling
Inputs:
src -- a ndimensional array (dim>2)
outshape -- fixed output shape for the first 2 dimensions
Outputs:
hout -- resulting n-dimensional array
"""
inh, inw = src.shape[:2]
outh, outw = outshape
hslice = (np.arange(outh) * (inh-1.)/(outh-1.)).round().astype(int)
wslice = (np.arange(outw) * (inw-1.)/(outw-1.)).round().astype(int)
hout = src[hslice, :][:, wslice]
return hout.copy()
评论列表
文章目录