Note
Go to the end to download the full example code.
2D Smoothing#
This example shows how to use the pylops.Smoothing2D
operator
to smooth a multi-dimensional input signal along two given axes.
import matplotlib.pyplot as plt
import numpy as np
import pylops
plt.close("all")
Define the input parameters: number of samples of input signal (N
and M
) and
lenght of the smoothing filter regression coefficients
(\(n_{smooth,1}\) and \(n_{smooth,2}\)). In this first case the input
signal is one at the center and zero elsewhere.
After applying smoothing, we will also try to invert it.
Aest = (Sop / B.ravel()).reshape(Sop.dims)
fig, axs = plt.subplots(1, 3, figsize=(10, 3))
im = axs[0].imshow(A, interpolation="nearest", vmin=0, vmax=1)
axs[0].axis("tight")
axs[0].set_title("Model")
plt.colorbar(im, ax=axs[0])
im = axs[1].imshow(B, interpolation="nearest", vmin=0, vmax=1)
axs[1].axis("tight")
axs[1].set_title("Data")
plt.colorbar(im, ax=axs[1])
im = axs[2].imshow(Aest, interpolation="nearest", vmin=0, vmax=1)
axs[2].axis("tight")
axs[2].set_title("Estimated model")
plt.colorbar(im, ax=axs[2])
plt.tight_layout()
Total running time of the script: (0 minutes 0.588 seconds)