File:Comparaison filtres median savitzky golay scipy.svg

Summary

Description
Français : Comparaison des filtres médian et de Savitzky-Golay mis en œuvre dans le module signal de la bibliothèque SciPy pour Python.
  • Gauche : filtre médian pour une fenêtre de largeur 7 points ;
  • droite : filtre de Savitzky-Golay pour un polynôme d'ordre 3 et une fenêtre de 7 points.
English: Comparison between the median and Savitzky-Golay filters implemented in the signal module of the Python SciPy library.
  • Left : median for a 7 points wide window;
  • droite : Savitzky-Golay for a 3rd order polynomial and a 7 points wide window.
Date
Source Own work
Author Cdang
W3CiThe source code of this SVG is invalid due to 10 errors.
 This W3C-invalid plot was created with Matplotlib.
Category:Invalid SVG created with Matplotlib#0100Comparaison%20filtres%20median%20savitzky%20golay%20scipy.svg
 The source code of this SVG is invalid due to 10 errors.
 This W3C-invalid vector image was created with Python by cdang.Category:Invalid SVG created with Python code#0100Comparaison%20filtres%20median%20savitzky%20golay%20scipy.svg

Source code

Python code

import numpy as np
import scipy.signal as signal
import matplotlib.pyplot as plt

epsilon = 0.1 # amplitude du bruit

x = np.linspace(0, 2, 40) # points d'abscisse

# Génération d'un signal gaussien bruité
y = 0.1*np.exp(-(10*(x - 1)*x + 0.125)) + epsilon*np.random.normal(x)

# Lissage
ylissemf = signal.medfilt(y, 7)
ylissesg = signal.savgol_filter(y, 7, 3)

# Affichage
fig, liste_axes = plt.subplots(1, 2, constrained_layout=True, figsize = [10, 6])
#fig = plt.figure(figsize = [10, 6])
liste_axes[0].plot(x, y, "b.")
liste_axes[0].plot(x, ylissemf, "k-", linewidth="0.5")
liste_axes[0].set_title("scipy.signal.medfilt(y, 7)")

liste_axes[1].plot(x, y, "b.")
liste_axes[1].plot(x, ylissesg, "k-", linewidth="0.5")
liste_axes[1].set_title("scipy.signal.savgol_filter(y, 7, 3)")

plt.savefig("comparaison_filtres_median_savitzky_golay_scipy.svg", format="svg")
Category:Files by User:cdang

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-4.0#Comparaison%20filtres%20median%20savitzky%20golay%20scipy.svg
Category:Self-published work
Category:Savitzky–Golay filter Category:Median filter Category:SciPy Category:Matplotlib
Category:CC-BY-SA-4.0 Category:Files by User:cdang Category:Invalid SVG created with Matplotlib Category:Invalid SVG created with Python code Category:Matplotlib Category:Median filter Category:Savitzky–Golay filter Category:SciPy Category:Self-published work