首页 > 学院 > 开发设计 > 正文

scipy.misc中的imresize

2019-11-06 08:25:02
字体:
来源:转载
供稿:网友
>>> from scipy.misc import imresize>>> import numpy as np>>> a = np.random.random(25).reshape([5,5])>>> aarray([[ 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))>>> barray([[ 68,  98, 116],       [145, 126,  68],       [169, 155, 122]], dtype=uint8)>>> c = imresize(a,(4,4))>>> carray([[ 55,  78, 157, 123],       [123, 126,  55,  57],       [174, 121, 133,  86],       [198, 142, 163, 122]], dtype=uint8)>>> d = imresize(a,(5,5))>>> darray([[ 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区间内


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表