Generate images via specialized methods.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
imageencoder/ascii_bin.py

24 lines
557 B

4 years ago
import numpy as np
import scipy.misc as smp
bit_on = [255, 255, 255] # RGB value if bit is 1
bit_off = [0, 0, 0] # RGB value if bit is 0
def translate_bit_color(bit:str):
if( bit == "1" ):
return bit_on
else:
return bit_off
def data_to_matrix(data:list) -> np.array:
newdat = [ [translate_bit_color(bit) for bit in byte] for byte in data ]
col_array = np.array(newdat, dtype=np.uint8)
return col_array
def main(inp:list) -> None:
col_array = data_to_matrix(inp)
img = smp.toimage(col_array)
img.show()