##傍から見たら仕事しろ!と怒られるデータフレーム
しかし、ちゃんと目的があります。
OpenCVはNumpyのndarray配列を使って、データを取り扱っています。
ってことは、グレーなら1次元、カラーなら3次元の配列をそのまま投げれば再現できんじゃん!
と、作法もルールも全く無視した変態チャレンジングをやってその度砕けました。
この度、作業が無事に終了しましたので
世の中の何の役にも立たないコードをアップします。
12×12の配列で配管工おじさんを描きました。
mario.py
import cv2
import numpy as np
val = 0
#空のリストを作成(12*12で全要素を0)
rchannel = [[val] * 12 for i in range(12)]
rchannel = np.array(rchannel)
gchannel = [[val] * 12 for i in range(12)]
gchannel = np.array(gchannel)
bchannel = [[val] * 12 for i in range(12)]
bchannel = np.array(bchannel)
#地獄の手打ちゾーン
rchannel[3,3:8] = 255
rchannel[4,2:11] = 255
rchannel[5,2:5] = 146
gchannel[5,2:5] = 41
bchannel[5,2:5] = 6
rchannel[5,5:7] = 248
gchannel[5,5:7] = 178
bchannel[5,5:7] = 108
rchannel[5,7] = 146
gchannel[5,7] = 41
bchannel[5,7] = 6
rchannel[5,8] = 248
gchannel[5,8] = 178
bchannel[5,8] = 108
rchannel[6,1] = 146
gchannel[6,1] = 41
bchannel[6,1] = 6
rchannel[6,2] = 248
gchannel[6,2] = 178
bchannel[6,2] = 108
rchannel[6,3] = 146
gchannel[6,3] = 41
bchannel[6,3] = 6
rchannel[6,4:7] = 248
gchannel[6,4:7] = 178
bchannel[6,4:7] = 108
rchannel[6,7] = 146
gchannel[6,7] = 41
bchannel[6,7] = 6
rchannel[6,8:11] = 248
gchannel[6,8:11] = 178
bchannel[6,8:11] = 108
rchannel[7,1] = 146
gchannel[7,1] = 41
bchannel[7,1] = 6
rchannel[7,2] = 248
gchannel[7,2] = 178
bchannel[7,2] = 108
rchannel[7,3:5] = 146
gchannel[7,3:5] = 41
bchannel[7,3:5] = 6
rchannel[7,5:8] = 248
gchannel[7,5:8] = 178
bchannel[7,5:8] = 108
rchannel[7,8] = 146
gchannel[7,8] = 41
bchannel[7,8] = 6
rchannel[7,9:11] = 248
gchannel[7,9:11] = 178
bchannel[7,9:11] = 108
rchannel[7,11] = 146
gchannel[7,11] = 41
bchannel[7,11] = 6
rchannel[8,1:3] = 146
gchannel[8,1:3] = 41
bchannel[8,1:3] = 6
rchannel[8,3:7] = 248
gchannel[8,3:7] = 178
bchannel[8,3:7] = 108
rchannel[8,7:11] = 146
gchannel[8,7:11] = 41
bchannel[8,7:11] = 6
rchannel[9,3:10] = 248
gchannel[9,3:10] = 178
bchannel[9,3:10] = 108
rchannel[10,2:4] = 255
bchannel[10,4] = 255
rchannel[10,5:9] = 255
rchannel[11,1:4] = 255
bchannel[11,4] = 255
rchannel[11,5:11] = 255
#チャンネルを結合
data_map = np.stack((bchannel,gchannel,rchannel),-1)
#データタイプを変更→これでOpenCVで扱える
data_map = np.array(data_map, dtype="uint8")
#可視化しやすいように拡大
data_map = cv2.resize(data_map, (400, 400),interpolation=cv2.INTER_NEAREST)
#表示
cv2.imshow("show",data_map)
cv2.waitKey(0)
cv2.destroyAllWindows()
2020年もよい1年になりますように。