File:Comparaison filtres median savitzky golay butterworth fft scipy.svg
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Size of this PNG preview of this SVG file: 800 × 480 pixels. Other resolutions: 320 × 192 pixels | 1,024 × 614 pixels | 1,280 × 768 pixels | 2,560 × 1,536 pixels | 900 × 540 pixels.
Original file (SVG file, nominally 900 × 540 pixels, file size: 100 KB)
File information
Structured data
Captions
Summary
[edit]DescriptionComparaison filtres median savitzky golay butterworth fft scipy.svg |
Français : Comparaison des filtres médian, de Savitzky-Golay, de Butterworth et de Fourier avec la bibliothèque SciPy de Python.
English: Comparison between the median filter, Savitzky-Golay filter, Butterworth filter and Fourier filter with the SciPy library for Python. |
Date | |
Source | Own work |
Author | Cdang |
iThe source code of this SVG is invalid due to 10 errors. |
This W3C-invalid plot was created with Matplotlib.
This W3C-invalid vector image was created with Python by cdang.
Source code
InfoField
Python code
import numpy as np
import scipy.signal as signal
import scipy.fft as fft
import matplotlib.pyplot as plt
# **************
# * Constantes *
# **************
epsilon = 0.1 # amplitude du bruit
# ******************************************
# * Génération d'un signal gaussien bruité *
# ******************************************
x = np.linspace(0, 4, 80) # points d'abscisse
y = 0.1*np.exp(-(10*(x - 1)*x + 0.125)) + epsilon*np.random.normal(x)
# ***********
# * Lissage *
# ***********
# filtre médian
ylissemf = signal.medfilt(y, 7)
# filtre de Savitzky-Golay
ylissesg = signal.savgol_filter(y, 7, 3)
# filtre de Butterworth
(b, a) = signal.butter(1, 5, fs=50) # caractéristiques du filtre
zi = signal.lfilter_zi(b, a) # conditions initiales du filtre
ylisseb = signal.lfilter(b, a, y, zi=zi*y[0]) # application du filtre
# filtre de Fourier
L = len(y) # longueur de signal
ff = fft.fftshift(fft.fft(y, fft.next_fast_len(L, real=True))) # calcule la transformée de Fourier rapide de manière optimisée
# en ajoutant des 0 en queue de signal, et ordonne les coefficients
ff[-25:] = 0 # atténuation du spectre aux extrémités
ff[:25] = 0
ylissef = fft.ifft(fft.ifftshift(ff))[:L] # réordonne les coefficients et calcule transformée de Fourier inverse,
# et élimine les 0 ajoutés artificiellement pour optimiser
# *************
# * Affichage *
# *************
fig, liste_axes = plt.subplots(2, 2, constrained_layout=True, figsize = [10, 6])
# filtre médian
liste_axes[0, 0].plot(x, y, "b.")
liste_axes[0, 0].plot(x, ylissemf, "k-", linewidth="0.5")
liste_axes[0, 0].set_title("scipy.signal.medfilt(y, 7)")
# filtre de Savitzky-Golay
liste_axes[0, 1].plot(x, y, "b.")
liste_axes[0, 1].plot(x, ylissesg, "k-", linewidth="0.5")
liste_axes[0, 1].set_title("scipy.signal.savgol_filter(y, 7, 3)")
# filtre de Butterworth
liste_axes[1, 0].plot(x, y, "b.")
liste_axes[1, 0].plot(x, ylisseb[0], "k-", linewidth="0.5")
liste_axes[1, 0].set_title("Butterworth (2, 0.3)")
# filtre de Fourier
liste_axes[1, 1].plot(x, y, "b.")
liste_axes[1, 1].plot(x, ylissef, "k-", linewidth="0.5")
liste_axes[1, 1].set_title("Filtre de Fourier")
plt.savefig("comparaison_filtres_median_savitzky_golay__butterworth_fft_scipy.svg", format="svg")
Licensing
[edit]I, the copyright holder of this work, hereby publish it under the following license:
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.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 08:59, 12 May 2023 | 900 × 540 (100 KB) | Cdang (talk | contribs) | Uploaded own work with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following page uses this file:
File usage on other wikis
The following other wikis use this file:
- Usage on fr.wikibooks.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Width | 720pt |
---|---|
Height | 432pt |