Black image when displaying an image
'exec(%matplotlib inline)'
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import pandas as pd
x_data = pd.read_csv('olivetti_X.csv');a = []
for i in range(len(x_data)):
X = np.array(x_data.iloc[i])
x = X.reshape(64,64)
plt.imshow(Image.fromarray(x), cmap = plt.get_cmap('gray'))
plt.show()
I can't understand why images are not output from the dataset, please help me understand
0
1 answers
Try to bring the values to the range 0-255:
X = (X * 255).astype(np.uint8)
1
Author: gil9red, 2020-02-27 10:39:49