1
如何调整N-D numpy图像的大小?如何调整N-D numpy图像的大小?
我不只是想对它进行二次采样,而是对像素进行插值/平均。
例如,如果我开始与
array([[[3, 1, 3, 1],
[3, 1, 3, 1],
[3, 1, 3, 1],
[3, 1, 3, 1]],
[[3, 1, 3, 1],
[3, 1, 3, 1],
[3, 1, 3, 1],
[3, 1, 3, 1]]], dtype=uint8)
和2中的所有尺寸的因素缩小它,我想输出是
array([[[2, 2],
[2, 2]]], dtype=uint8)
尝试的解决方案:
A. SciPy ndimage:
>>> scipy.ndimage.interpolation.zoom(x, .5, mode='nearest')
array([[[3, 1],
[3, 1]]], dtype=uint8)
(可选order
参数没有区别)
B.遍历2**3
可能发生偏移:丑陋的,缓慢的,仅适用于整数缩放因子,并且需要额外的步骤,以避免溢出。
C. OpenCV和PIL仅适用于2D图像。