我尝试使用以下函数:def randomChose(bp, xsteps, ysteps, bs):
# Number of points to be chosen
s = int((bp * xsteps * ysteps) / (bs * bs))
# Generating an array representing the input indexes
indices = numpy.arange(xsteps * ysteps)
# Resampling without replacement
cs = npr.choice(indices, size=s, replace=False)
f = []
for idx in cs:
nb = indices[max(idx-(bs*bs/2), 0):min(idx+(bs*bs/2)+1, xsteps*ysteps)]
f.append(nb)
f = numpy.array(f).flatten()
fix = numpy.unique(numpy.array(f))
return fix
它以数字bp、数据维度xsteps*ysteps和%bs作为参数。在
我要做的是选择一些有效的索引来考虑这个图像中的某个邻域。在
但是,在调用numpy.unique时,我一直收到错误消息,但并不总是这样:
^{pr2}$
我这样称呼它:nx = 57.2
ny = 24.0
xsteps = 144
ysteps = 106
bs = 5 # Block size
bp = 0.1 # Percentage of blocks
fix = randomChose(bp, xsteps, ysteps, bs)
我试图理解什么是错的。据我所知,这种方法需要一个ndarray作为输入,这是给定的。在
谢谢你的帮助。在