回答

2

你想scipy.ndimage.zoom,可以使用如下:

>>> x = np.arange(8, dtype=np.float_).reshape(2, 2, 2) 
>>> scipy.ndimage.zoom(x, 1.5, order=1) 
array([[[ 0. , 0.5, 1. ], 
     [ 1. , 1.5, 2. ], 
     [ 2. , 2.5, 3. ]], 

     [[ 2. , 2.5, 3. ], 
     [ 3. , 3.5, 4. ], 
     [ 4. , 4.5, 5. ]], 

     [[ 4. , 4.5, 5. ], 
     [ 5. , 5.5, 6. ], 
     [ 6. , 6.5, 7. ]]]) 

請注意,該函數總是保留圖像的邊界,基本與重採樣每個像素中心節點的網格。如果您需要更多地控制重新採樣發生的位置,您可能需要查看scipy.ndimage中的其他功能