opencv for python
1. 安装方法(windows下面)
http://blog.csdn.net/qq_14845119/article/details/52354394
2. 将含有随机字节的bytearray转换为灰度图像和BGR图像:
1 import cv2 2 import numpy 3 import os 4 randomByteArray = bytearray(os.urandom(12000)) 5 flatNumpyArray = numpy.array(randomByteArray) 6 grayImage = flatNumpyArray.reshape(300,400) 7 cv2.imwrite(‘RandomGray.png‘,grayImage) 8 bgrImage = faltNumpyArray.reshape(100,400,3) 9 cv2.imwrite(‘RandomColor.png‘,bgImage)
如果你运行该脚本,会随及生成两个图像,位于脚本所在的目录下面
时间: 2024-11-29 02:36:57