アンシャープマスキング#

アンシャープマスキングとは、画像をシャープにする線形画像処理手法です。シャープな詳細は、元の画像とそのぼかされたバージョンとの差として識別されます。これらの詳細は拡大され、元の画像に戻されます。

強化された画像 = 元の画像 + 量 * (元の画像 - ぼかされた画像)

ぼかしステップでは、中央値フィルタなど、任意の画像フィルタメソッドを使用できますが、従来はガウスフィルタが使用されます。アンシャープマスキングフィルタの半径パラメータは、ガウスフィルタのシグマパラメータを参照します。

この例では、半径と量のパラメータが異なる場合の効果を示します。

Original image, Enhanced image, radius=1, amount=1.0, Enhanced image, radius=5, amount=2.0, Enhanced image, radius=20, amount=1.0
from skimage import data
from skimage.filters import unsharp_mask
import matplotlib.pyplot as plt

image = data.moon()
result_1 = unsharp_mask(image, radius=1, amount=1)
result_2 = unsharp_mask(image, radius=5, amount=2)
result_3 = unsharp_mask(image, radius=20, amount=1)

fig, axes = plt.subplots(nrows=2, ncols=2, sharex=True, sharey=True, figsize=(10, 10))
ax = axes.ravel()

ax[0].imshow(image, cmap=plt.cm.gray)
ax[0].set_title('Original image')
ax[1].imshow(result_1, cmap=plt.cm.gray)
ax[1].set_title('Enhanced image, radius=1, amount=1.0')
ax[2].imshow(result_2, cmap=plt.cm.gray)
ax[2].set_title('Enhanced image, radius=5, amount=2.0')
ax[3].imshow(result_3, cmap=plt.cm.gray)
ax[3].set_title('Enhanced image, radius=20, amount=1.0')

for a in ax:
    a.axis('off')
fig.tight_layout()
plt.show()

スクリプトの総実行時間: (0 分 1.751 秒)

Sphinx-Gallery で生成されたギャラリー