def writeBinaray(outputFile, imagePath, label):
img = Image.open(imagePath)
img = img.resize((imageSize, imageSize), PIL.Image.ANTIALIAS)
img = (np.array(img))
r = img[:,:,0].flatten()
g = img[:,:,1].flatten()
b = img[:,:,2].flatten()
label = [label]
out = np.array(list(label) + list(r) + list(g) + list(b), np.uint8)
outputFile.write(out.tobytes())
# if you want to show the encoded image. set up 'debugEncodedImage' flag
if debugEncodedImage:
showImage(r, g, b)
评论列表
文章目录