在opencv中处理图像时,可以看到所有生成的矩阵类型都是uint8。
import c v2 ascvimg=cv.im read (hello.png ) print ) img ) array([.]、[.]、[.]、dtype='uint8' ) uint8
1:numpy中有np.uint8) )函数,但该函数只有原数据和0xff相(和最少2字节的数据相),因此在原数据大于255的情况下,np.uint8
a=[ 2000,100,2 ]在NP.uint8(a ) array ) [ 208,100,2 ],dtype=uint8) 3358www.Sina.com/cv2.normalize函数中匹配
cv2.normalize(img,out,0,255,cv2.NORM_MINMAX ) )然后更改数据类型
NP.Array([out],dtype=‘uint 8’)2:
要将当前数组作为图像类型执行各种操作,必须将其转换为uint8类型。 建议使用第二种转换方法。 第一,大于255的值容易丢失。
3358 www.Sina.com/: https://blog.csdn.net/QQ _ 39751320/article/details/104849194