【python下使用OpenCV實現計算機視覺讀書筆記2】圖像與字節的變換
阿新 • • 發佈:2018-02-05
ng- == color and pytho avi data- imwrite center
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】圖像與字節的變換