はじめに
画像を2×2,4×4や8×8に分割して表示する方法について説明する。
コード

解説
モジュールのインポート
画像の読み込み

エピテランサ 月世界の発芽後4ヶ月の画像を用いる。画像の大きさは800×800となっている。
画像を分割し、Imagegrid で表示する関数
画像の分割
image_listという空のリストを作成して、それに分割した画像を加えていく方法で画像の分割を行う。
divは分割数であり、2とした場合には2×2=4個に分割される。
Imagegridによる分割画像の表示
axes_padにより画像間の間隔を調整できる。
画像の表示
4×4に分割した画像の表示

8×8に分割した画像の表示

参考

numpyで画像の分割と連結 - Qiita
Deep Learning等で大きな画像をいくつかに分割したり、分割した画像を結合させたりすることがよくあるが、まとまった記事がなさそうだったのでメモ。動作環境Ubuntu 16.04Pyth…

[matplotlib] 19. mpl_toolkits.axes_grid1 の使い方(画像の表示)
axes_grid1のImageGridを用いて複数の画像を表示する方法
コメント