Removing high frequency noise from gyroscope data
This example shows how to remove high-frequency emissions from streaming data using the MedianFilter block from the EngeeDSP library.
A median filter is a non-linear digital filtering technique often used to remove noise from an image or signal.
The implementation of this algorithm starts by connecting the libraries:
Pkg.add(["DelimitedFiles"])
import .EngeeDSP
using DelimitedFiles
using Plots
plotlyjs()
Loading a signal with high-frequency noise from the JL file is the Julia source code file.
matrix = readdlm("$(@__DIR__)/data.jl", '\t', Float64, '\n');
Encoding the file into 714 samples so that each column of data contains 10 frames.
In1 = map(Iterators.partition(axes(matrix,1), 714)) do cols
matrix[cols,:]
end
Implementing filtering, the system uses a window length of 10.
var_median_fir = EngeeDSP.MedianFilter(WindowLength = 10)
EngeeDSP.setup!( var_median_fir, In1[1] )
Out1 = In1
for i = 1:10 # Обработка сигнала в цикле.
global gyroData = In1[i]
global filteredData = EngeeDSP.step!(var_median_fir,gyroData)
Out1[i] = filteredData
end
Out1 = vcat(Out1...)
Create a graph of the object to view the filtered output and compare it to the input signal with noise.
plot( [matrix[:,3],Out1[:,3]], ylims = [-300, 300], label=["Входной сигнал" "Отфильтрованный выход"], legendfontsize=6)
Conclusion
In this example we have demonstrated the possibilities of using in the Engee development environment additional libraries that extend the functionality of the environment, namely the EngeeDSP library and the MedianFilter implemented in it.