[Solved] How to Enter a sequence of alphabet in 9×9 matrix and then the alphabet put values in that matrix to create an image in python, how do i do that? [closed]


Here is an example of how to do what you are asking:

# Create string of 81 uppercase letters
string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'*3 + 'ABC'

# Assign each letter a number, and scale the numbers from 0 to 1
num = [(ord(string[char]) - 65)/25 for char in range(len(string))]

# Assemble the numbers into a 9x9 matrix
x = np.reshape(num,[9,9])

# Create an image with the color defined by the numbers
plt.imshow(x)

# Loop over data dimensions and create text annotations
idx = -1
for i in range(x.shape[0]):
    for j in range(x.shape[1]):
        idx += 1
        text = plt.gca().text(j, i, string[idx],
                       ha="center", va="center", color="w")

Image from letters

2

solved How to Enter a sequence of alphabet in 9×9 matrix and then the alphabet put values in that matrix to create an image in python, how do i do that? [closed]