Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement low pass filter using java

I am trying to implement a low pass filter in Java. My requirement is very simple,I have to eliminate signals beyond a particular frequency (Single dimension). Looks like Butterworth filter would suit my need.

Now the important thing is that CPU time should be as low as possible. There would be close to a million sample the filter would have to process and our users don't like waiting too long. Are there any readymade implementation of Butterworth filters which has optimal algorithms for filtering.

like image 982
chai Avatar asked Oct 26 '10 18:10

chai


People also ask

Which of the following is a low pass filter?

Explanation: Lowpass filters are considered of three types: Ideal, Butterworth, and Gaussian.

Why is filtering necessary?

The filter fibres have to allow sufficient air to pass through – without offering too much resistance – while also trapping harmful particles. This is the strength of good filters. A human being inhales and exhales some twenty kilograms of air daily.


1 Answers

I have a page describing a very simple, very low-CPU low-pass filter that is also able to be framerate-independent. I use it for smoothing out user input and also for graphing frame rates often.

http://phrogz.net/js/framerate-independent-low-pass-filter.html

In short, in your update loop:

// If you have a fixed frame rate smoothedValue += (newValue - smoothedValue) / smoothing  // If you have a varying frame rate smoothedValue += timeSinceLastUpdate * (newValue - smoothedValue) / smoothing 

A smoothing value of 1 causes no smoothing to occur, while higher values increasingly smooth out the result.

The page has a couple of functions written in JavaScript, but the formula is language agnostic.

like image 72
Phrogz Avatar answered Oct 04 '22 09:10

Phrogz