Basic median filter

2015.10.06 DW KT


In [6]:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import sys
sys.path.insert(0, 'C:\Users\Dominik\Documents\GitRep\kt-2015-DSPHandsOn\MedianFilter\Python') #Add a new path with needed .py files

import functions
import gitInformation

In [7]:
%matplotlib inline

In [8]:
gitInformation.printInformation()


Information about this notebook
============================================================
Date: 2015-11-10
Python Version: 2.7.10 |Anaconda 2.3.0 (64-bit)| (default, May 28 2015, 16:44:52) [MSC v.1500 64 bit (AMD64)]
Git directory: C:\Users\Dominik\Documents\GitRep\kt-2015-DSPHandsOn\.git
Current git SHA: e97abbdc8e14f36135d6bc97ab7fc7f95bd8b90b
Remotes: fork, origin, 
Current branch: master
fork remote URL: http://github.com/dowa4213/kt-2015-DSPHandsOn.git
origin remote URL: https://github.com/ktakagaki/kt-2015-DSPHandsOn.git

Testing the median filter with a fixed window length of 16.


In [4]:
median = plt.figure(figsize=(30,20))
for x in range(1, 5):
    for y in range(1, 6):
        plt.subplot(5, 5, x + (y-1)*4)
        wavenum = (x-1) + (y-1)*4
        functions.medianSinPlot(wavenum, 15)
        plt.suptitle('Median filtered Sine Waves with window length 15', fontsize = 60)
        plt.xlabel(("Wave number = "+str((x-1) + (y-1)*4)), fontsize=18)


Summary

  • with higher wave numbers (n=10), the filter makes the signal even worse with a phase (amplitude) reversal!
  • a bit of ailiasing, would benefit from more sample points

Graphic Export


In [5]:
pp=PdfPages( 'median sin window length 15.pdf' )
pp.savefig( median )
pp.close()