Ejemplo n.º 1
0
import matplotlib.pyplot as plt

from supreme.io import imread
from supreme.noise import dwt_denoise

import demo_data

X = demo_data.chelsea()

noise = np.random.normal(loc=0, scale=30, size=X.shape)
X_ = X + noise
X_ = np.clip(X_, 0, 255)
X_ /= X_.max()

Y = np.clip(dwt_denoise(X_, wavelet='db16', alpha=0.02, levels=4), 0, 255)
Y /= Y.max()

print "MSE:", np.mean((X - Y)**2)/np.prod(X.shape)

plt.subplot(2, 2, 1)
plt.imshow(X)
plt.title('Input Image')

plt.subplot(2, 2, 2)
plt.imshow(X_)
plt.title('Severe Noise Added')

plt.subplot(2, 2, 3)
plt.imshow(Y)
plt.title('Wavelet Filtered')
Ejemplo n.º 2
0
# --------------------------------------
alpha = 2
# --------------------------------------

if len(sys.argv) == 1:
    print "Usage: noise_fingerprint.py file1 file2 file3 ..."

ic = ImageCollection(sys.argv[1:10])

n = []
denoise = []
for i, img in enumerate(ic):
    print "Denoising image %d..." % i

    clean = dwt_denoise(img, wavelet='db8', alpha=alpha, levels=4)

    if i == 0:
        denoise.append(clean)

    n.append(img - clean)

avg = np.zeros(n[0].shape, dtype=float)
for noise in n:
    avg += noise
avg /= len(n)

print "Noise minimum and maximum:", avg.min(), avg.max()

imdata = avg + avg.min()
imdata = imdata / imdata.max()