def finite_and_within_bounds(xys, shape):
H, W = shape[:2]
if not len(xys):
return np.array([])
return np.bitwise_and(np.isfinite(xys).all(axis=1),
reduce(lambda x,y: np.bitwise_and(x,y), [xys[:,0] >= 0, xys[:,0] < W,
xys[:,1] >= 0, xys[:,1] < H]))
评论列表
文章目录