numpy处理图像

版权声明:欢迎转载请注明转自方辰昱的博客https://blog.csdn.net/viafcccy https://blog.csdn.net/viafcccy/article/details/88806379

 图片在计算机中中以矩阵的方式保存,使用np对矩阵处理有两个好处

1.np是py专门进行数组操作的库有较多函数

2.针对py性能优化对于大的数据矩阵有更好的操作性

import cv2
import numpy as np
img = np.zeros((300,300)) #生成一个300*300的零矩阵
img[0,0] = 255 #设置右上角的点为白色
cv2.imshow("test",img)
cv2.waitKey(0)
import cv2
import numpy as np
img = np.zeros((300,300)) #生成一个300*300的零矩阵
img[:,0] = 255
img[10,:] = 255
cv2.imshow("test",img)
cv2.waitKey(0)

猜你喜欢

转载自blog.csdn.net/viafcccy/article/details/88806379