はじめに
jupyter notebook, labで対話的にパラメータを調整できる機能(ipywidgets Dropdown)を使って、画像に任意の補間方法を適用する方法について説明する。
コード

解説
モジュールのインポートなど
バージョン
補間方法リストの作成
データの生成
画像データは下記記事と同じコードにより生成した。

[matplotlib] 57. plt.imshow()で軸を画像から離して表示
matplotlibのplt.imshowで画像を表示する際に、軸を画像から離して表示する方法について説明する。
画像の表示
ax.imshowで画像を表示し、make_axes_locatableにappend_axesをしてカラーバーを表示する。interpolationについては”None”にしておく。
ドロップダウンボックスの設定
options=methodsでリスト内の要素をドロップダウン形式で選択できるようになる。
ドロップダウンボックスを変更した場合の操作
img.set_interpolation(change[‘new’])により、画像の補間方法を変化させる。
widgetsの表示
observeを用いてwidgetsを動作させる。displayで表示する。
Example
none

nearest

antialiased

bilinear

bicubic

spline16

spline36

hanning

hamming

hermite

kaiser

quadric

catrom

gaussian

bessel

mitchell

sinc

lanczos

参考
Widget Events — Jupyter Widgets 8.1.5 documentation
https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html
コメント