python NSST
时间: 2023-11-30 13:43:39 浏览: 224
根据提供的引用内容,我们可以得知NSST是对剪切波变换的改进,避免了伪吉布斯现象的出现,相比于小波变换、曲边变换等操作效率高、复杂度低。下面是一个Python实现的NSST的例子:
```python
import numpy as np
import pywt
from scipy import signal
from skimage import data, img_as_float
from skimage.color import rgb2gray
from skimage.transform import resize
from nsst import nsstDecomp2, nsstRec2
# 读取图像并转换为灰度图像
img = img_as_float(data.astronaut())
img = resize(rgb2gray(img), (256, 256))
# NSST分解
nlevel = 3
scales = range(1, nlevel + 1)
wavelet = pywt.Wavelet('db2')
dec = nsstDecomp2(img, scales, wavelet)
# NSST重构
rec = nsstRec2(dec, wavelet)
# 显示原始图像和重构图像
import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(8, 5))
ax[0].imshow(img, cmap='gray')
ax[0].set_title('Original image')
ax[1].imshow(rec, cmap='gray')
ax[1].set_title('Reconstructed image')
plt.show()
```
阅读全文