3.3.11.1. 画像の作成

NumPyの基本的なコマンドで画像を作成する方法 : np.zeros, スライシング...

この例では、シンプルなチェッカーボードの作り方を紹介します。

plot check
import numpy as np
import matplotlib.pyplot as plt
check = np.zeros((8, 8))
check[::2, 1::2] = 1
check[1::2, ::2] = 1
plt.matshow(check, cmap="gray")
plt.show()

Total running time of the script: (0 minutes 0.036 seconds)

Gallery generated by Sphinx-Gallery