の完全な配列から黒画像イントロmatplotlibのは、私が<code>matplotlib.pyplot</code>でいくつかのテストをやっているもの
を生成します。私は人工的な画像を保存しようとしたとき、私は奇妙な動作をencoutered。ここで私は、画像を保存するために作成した非常にシンプルな機能は次のとおりです。私はゼロの完全な配列で画像を作成しようとすると、予想通り
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
def save_image(array, name):
array = array*255.
fig = plt.figure()
plt.imsave(name, array.astype('uint8'), cmap=matplotlib.cm.gray)
plt.close(fig)
return 0
問題
、私は、暗い画像を取得します:しかし
zeros_array = np.zeros((200,200), dtype='float')
save_image(zeros_array, 'Dark.jpg')
、私はものの完全な配列で画像を作成しようと、私はまだ暗い画像を取得:興味深いことに
ones_array = np.ones((200,200), dtype='float')
save_image(ones_array, 'White.jpg')
を、私はmixed_array
を作成するときに、異なる強度の二乗で、ものの完全な領域は今、白として表示されます:
mixed_array = np.ones((200,200), dtype='float')
mixed_array[:100,:100] = 0.25
mixed_array[100:,100:] = 0.75
save_image(mixed_array, 'Mixed.jpg')
質問:
matplotlib
は完全な白い画像を保存することを拒否しますが、画像の白い領域に問題はないことを知っていますか?
私はおそらく非常に明白か基本的なものを見逃していますが、私は何が見えません。