scipy.misc.imresize

此函数的作用是: 对图像进行成比例放大或缩小,且归一化到0-255区间

https://blog.csdn.net/u013066730/article/details/59528939

>>> from scipy.misc import imresize
>>> import numpy as np
>>> a = np.random.random(25).reshape([5,5])
>>> a
array([[ 0.24677501,  0.08400788,  0.52535783,  0.98557437,  0.46538628],
       [ 0.14449665,  0.78652476,  0.02484598,  0.12847917,  0.17554679],
       [ 0.87219052,  0.3594529 ,  0.80304335,  0.17892899,  0.39732472],
       [ 0.80995837,  0.1105192 ,  0.89232289,  0.37695266,  0.34482325],
       [ 0.87255292,  0.64613089,  0.54023177,  0.7348253 ,  0.46107425]])
>>> b = imresize(a,(3,3))
>>> b
array([[ 68,  98, 116],
       [145, 126,  68],
       [169, 155, 122]], dtype=uint8)
>>> c = imresize(a,(4,4))
>>> c
array([[ 55,  78, 157, 123],
       [123, 126,  55,  57],
       [174, 121, 133,  86],
       [198, 142, 163, 122]], dtype=uint8)
>>> d = imresize(a,(5,5))
>>> d
array([[ 59,  16, 133, 255, 117],
       [ 32, 202,   0,  28,  40],
       [225,  89, 207,  41,  99],
       [208,  23, 230,  93,  85],
       [225, 165, 137, 188, 116]], dtype=uint8)

上面数值从小数变成几百,这是因为需要讲这些小数一一对应到0到255区间内

https://blog.csdn.net/zz2230633069/article/details/82391597   讲的也挺详细

猜你喜欢

转载自blog.csdn.net/infinita_LV/article/details/86221407