码迷,mamicode.com
首页 > 编程语言 > 详细

【python下使用OpenCV实现计算机视觉读书笔记2】图像与字节的变换

时间:2018-02-05 12:44:27      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:nump   tracking   data   分享图片   col   stat   技术分享   tis   ack   




import cv2
import numpy
import os
# Make an array of 120,000 random bytes.
randomByteArray = bytearray(os.urandom(120000))

flatNumpyArray = numpy.array(randomByteArray)
# Convert the array to make a 400x300 grayscale image.
grayImage = flatNumpyArray.reshape(300, 400)
cv2.imwrite(‘RandomGray.png‘, grayImage)
# Convert the array to make a 400x100 color image.
bgrImage = flatNumpyArray.reshape(100, 400, 3)
cv2.imwrite(‘RandomColor.png‘, bgrImage)

技术分享图片

技术分享图片

【python下使用OpenCV实现计算机视觉读书笔记2】图像与字节的变换

标签:nump   tracking   data   分享图片   col   stat   技术分享   tis   ack   

原文地址:https://www.cnblogs.com/llguanli/p/8416752.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!