Pythonで以下の白黒画像の主成分分析をして復元しました。
白黒の画像で復元されることを望んでいたのですが色付きで表示されました。何が原因なのでしょうか。
Python
1from PIL import Image 2from sklearn.decomposition import PCA 3import numpy as np 4import matplotlib.pyplot as plt 5 6# store image to array 7arr = np.asarray(Image.open("flower.jpg")) 8 9# execute pca and restore image 10pca = PCA(n_components=50) 11pca.fit(arr) 12pca_res = pca.transform(arr) 13restoredImg = pca.inverse_transform(pca_res) 14 15# show restored image 16plt.imshow(restoredImg);
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。