LoginSignup
0
1

More than 3 years have passed since last update.

jupyterlab で画像を 2D 数値データとして plot したいときのメモ

Last updated at Posted at 2021-03-12

背景

Jupyterlab で RAW 画像データの値を見たい.
画像処理とかしたあとの値の違いとかを見たい.

などで, 画像データを 2D 数値マップとしてみたいときがあります.

カラーバーつき plot

単に imshow(グレースケール画像)だとどの色がどの値に対応するかがわかりません.

colorbar をつける必要がありますが, imshow(cbar=True) みたいにお手軽ぺろっとできるわけではなくて, 一旦 subplots を作る必要がありました.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
pos = ax.imshow(img)
fig.colorbar(pos)

値の範囲を指定したい.

HDR 画像のようにダイナミックレンジが大きい画像で特定の範囲だけみたいときなど.

imshow(img, vmin=0.5, vmax=100) のように vmin, vmax で範囲を指定できます.

interactive plot モード

%matplotlib widget

をつけることで, マウス位置のピクセル値を出したりできる.
ただし notebook ごとに一個しか表示できないっぽいので, 複数画像プロットしたいときには使えない.

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1