Skip to content

Instantly share code, notes, and snippets.

@peace098beat
Created September 10, 2021 08:04
Show Gist options
  • Save peace098beat/de1fd918b293b97e374d7363391ae8a1 to your computer and use it in GitHub Desktop.
Save peace098beat/de1fd918b293b97e374d7363391ae8a1 to your computer and use it in GitHub Desktop.
[ASCII] #python #ascii
import cv2
density = list("MWN$@%#&B89EGA6mK5HRkbYT43V0JL7gpaseyxznocv?jIftr1li*=-~^`':;,. ")
LEN = len(density)
def image_print(image, wid=30):
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
resized = cv2.resize(gray, (int(wid*2),int(wid)))
for i in range(resized.shape[0]):
s = ""
for j in range(resized.shape[1]):
s += density[(LEN-1)-resized[i][j]//(256//LEN)]
print(s)
if __name__ == '__main__':
img = cv2.imread("genbaneko.jpeg")
image_print(img, 60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment