python OpenCV学习笔记(四):Numpy数组操作
2019-02-25 12:27
423 查看
文章目录
遍历数组中的每个像素点
修改数组中像素点的值
data\dtype\size\shape\len
1.对图像中的每一个像素点进行处理
def access_pixels(image): print(image.shape) height = image.shape[0] width = image.shape[1] channels = image.shape[2] print("width : %s , height : %s , channels : %s"%(width, height, channels)) for row in range(height): for col in range(width): for c in range(channels): pv = image[row, col, c] image[row, col, c] = 255-pv cv.imshow("pixels_demo",image)
注:像素取反有简便方法
cv.bitwise_not(image)
2.创建一个自定义的图像
def create_image(): img = np.zeros([400, 400, 3], np.uint8) img[: , : , 0] = np.ones([400, 400])*255 cv.imshow("new image", img)
相关文章推荐
- python numpy操作数组学习笔记(二)数组的分割和组合
- Python学习笔记之NumPy基本操作(数组)
- 【python学习笔记】17:numpy数组排序
- 【python学习笔记】18:numpy数组函数与矩阵运算
- 学习Python数据分析随手笔记【二】numpy数组的属性
- Python Numpy学习(三)数组形状操作
- Python学习笔记5-字符串、bool、数值操作和数组字典排序
- python初学者学习笔记(二)数组的操作
- 学习Python数据分析(2.1)----Numpy数组以及数组的操作
- Python学习笔记5-字符串、bool、数值操作和数组字典排序
- Python学习笔记3-Python元组、数组、字典集合的操作
- Python学习笔记3-Python元组、数组、字典集合的操作
- Python学习笔记5-字符串、bool、数值操作和数组字典排序
- Python OpenCV学习笔记之:图像数学形态操作
- python OpenCV学习笔记(六):图片的基本操作
- Python.Numpy学习零碎笔记之数组与矩阵
- Python学习笔记5-字符串、bool、数值操作和数组字典排序
- Python3.4学习笔记之列表、数组操作示例
- Python OpenCV学习笔记之:图像阈值操作
- Python OpenCV 学习笔记之:基本操作