Sho*_*pon 4 python numpy image-processing
在包numpy他们是两个函数调整大小和重塑.内部如何运作?他们使用什么样的插值?我查看了代码,但没有得到它.谁能帮我吗.或者如何调整图像大小.它的像素会发生什么?
插值都没有.如果您想知道图像的插值和像素,它们可能不是您想要的功能.有一些image包(例如in scipy)操纵图像的分辨率.
每个numpy数组都有一个shape属性. reshape只是改变它,而不改变数据.新形状必须引用与原始形状相同的元素总数.
x = np.arange(12)
x.reshape(3,4) # 12 elements
x.reshape(6,2) # still 12
x.reshape(6,4) # error
Run Code Online (Sandbox Code Playgroud)
np.resize不太常用,但是用Python编写并可用于研究.你必须阅读它的文档,并且x.resize是不同的.越大,它实际上会用零重复值或填充.
在1d中调整大小的示例:
In [366]: x=np.arange(12)
In [367]: np.resize(x,6)
Out[367]: array([0, 1, 2, 3, 4, 5])
In [368]: np.resize(x,24)
Out[368]:
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11])
In [369]: x.resize(24)
In [370]: x
Out[370]:
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0])
Run Code Online (Sandbox Code Playgroud)
最近的一个问题scipy.misc.imresize.它还引用了scipy.ndimage.zoom:
| 归档时间: |
|
| 查看次数: |
8517 次 |
| 最近记录: |