Signal Inpainting

Reconstructs a smooth signal across the USA grid using only a small fraction (e.g., 0.1%) of known data points via iterative low-pass filtering.

Signal Inpainting
from sgwt import DyConvolve
from sgwt import DELAY_USA as L
from sgwt import COORD_USA as C
import numpy as np

SAMPLE_FRACTION = 0.005
N_ITERATIONS = 100
SMOOTHING_SCALE = 50.0
STEP_SIZE = 1
n_nodes = L.shape[0]

X_true = C[:, 0:1].copy(order='F')

n_samples = int(n_nodes * SAMPLE_FRACTION)
sample_indices = np.random.choice(n_nodes, n_samples, replace=False)
J_mask = np.isin(np.arange(n_nodes), sample_indices)
X_sampled = np.zeros_like(X_true)
X_sampled[J_mask] = X_true[J_mask]

Xh = np.zeros_like(X_true, order='F')

with DyConvolve(L, poles=[1/SMOOTHING_SCALE]) as conv:
    for i in range(N_ITERATIONS):
        error = np.zeros_like(Xh)
        error[J_mask] = X_sampled[J_mask] - Xh[J_mask]
        smoothed_error = conv.lowpass(error)[0]
        Xh += STEP_SIZE * smoothed_error * SMOOTHING_SCALE
Signal Inpainting Reconstruction Example