yong old code in separate file; writing bitmap program to extend towards the framework of kinecam

main
onebigear 2 years ago
parent 286c39168e
commit 65a0e12dc1

@ -1,128 +0,0 @@
import numpy as np
import seaborn as sns; sns.set()
# todo
# https://auth0.com/blog/image-processing-in-python-with-pillow/
# https://stackoverflow.com/questions/46385999/transform-an-image-to-a-bitmap
# text to image
# image to bitmap
# bitmap to random
# export bitmaps to a gallery
# bitmap to hardware display (no time)
# clear randomization; reassign var yong_grid hold values of original text input matrix
# add annotation to specify level of randomization
# run 100 times and save pictures
# a representation of "永" in matrix notation
yong_grid = [[0,0,0,0,1,1,0,0,0,0],
[0,0,1,1,1,1,0,0,1,0],
[0,0,0,0,0,1,0,1,0,0],
[0,0,0,0,0,1,1,0,0,0],
[0,1,1,1,1,1,1,0,0,0],
[0,0,0,1,0,1,1,0,0,0],
[0,0,1,0,0,1,0,1,0,0],
[0,1,0,0,0,1,0,0,1,0],
[0,0,0,1,0,1,0,0,0,0],
[0,0,0,0,1,1,0,0,0,0]]
print(np.matrix(yong_grid))
ax = sns.heatmap(yong_grid, annot=True, fmt="d")
plt.show()
from matplotlib import pyplot as plt
im = plt.imshow(yong_grid, cmap="copper_r")
plt.show()
# access item in matrix
# notation is [column][row]
print(yong_grid[0][4])
print(yong_grid[0][5])
twenty_p_one = [1,1,0,0,0,0,0,0,0,0]
twenty_p_zero = [0,0,1,1,1,1,1,1,1,1]
import random
import math
z_count = 0
one_count = 0
import math
for i in range(10):
for j in range(10):
if yong_grid[i][j] == 0:
# reassign
yong_grid[i][j] = random.choice(twenty_p_one)
else:
yong_grid[i][j] = random.choice(twenty_p_zero)
ax = sns.heatmap(yong_grid, annot=True, fmt="d")
# lists for 5%, 10% and 15% randomization
five_p_one = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
five_p_zero = [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
ten_p_one = [1,0,0,0,0,0,0,0,0,0]
ten_p_zero = [0,1,1,1,1,1,1,1,1,1]
fifteen_p_one = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
fifteen_p_zero = [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
# random image generator
# generate heatmap and save in folder
def randImg(list_zero, list_one):
z_count = 0
one_count = 0
for i in range(10):
for j in range(10):
if yong_grid[i][j] == 0:
yong_grid[i][j] = random.choice(list_zero)
else:
yong_grid[i][j] = random.choice(list_one)
ax = sns.heatmap(yong_grid, annot=True, fmt="d")
# clear randomization; reassign var yong_grid hold values of original text input matrix
# call function with 5%
# clear randomization; reassign var yong_grid hold values of original text input matrix
yong_grid = [[0,0,0,0,1,1,0,0,0,0],
[0,0,1,1,1,1,0,0,1,0],
[0,0,0,0,0,1,0,1,0,0],
[0,0,0,0,0,1,1,0,0,0],
[0,1,1,1,1,1,1,0,0,0],
[0,0,0,1,0,1,1,0,0,0],
[0,0,1,0,0,1,0,1,0,0],
[0,1,0,0,0,1,0,0,1,0],
[0,0,0,1,0,1,0,0,0,0],
[0,0,0,0,1,1,0,0,0,0]]
randImg(five_p_zero, five_p_one)
# call function with 10%
yong_grid = [[0,0,0,0,1,1,0,0,0,0],
[0,0,1,1,1,1,0,0,1,0],
[0,0,0,0,0,1,0,1,0,0],
[0,0,0,0,0,1,1,0,0,0],
[0,1,1,1,1,1,1,0,0,0],
[0,0,0,1,0,1,1,0,0,0],
[0,0,1,0,0,1,0,1,0,0],
[0,1,0,0,0,1,0,0,1,0],
[0,0,0,1,0,1,0,0,0,0],
[0,0,0,0,1,1,0,0,0,0]]
randImg(ten_p_zero, ten_p_one)
# fifteen percent
yong_grid = [[0,0,0,0,1,1,0,0,0,0],
[0,0,1,1,1,1,0,0,1,0],
[0,0,0,0,0,1,0,1,0,0],
[0,0,0,0,0,1,1,0,0,0],
[0,1,1,1,1,1,1,0,0,0],
[0,0,0,1,0,1,1,0,0,0],
[0,0,1,0,0,1,0,1,0,0],
[0,1,0,0,0,1,0,0,1,0],
[0,0,0,1,0,1,0,0,0,0],
[0,0,0,0,1,1,0,0,0,0]]
randImg(fifteen_p_zero, fifteen_p_one)
Loading…
Cancel
Save