berndporr / iirj

An efficient IIR filter library written in JAVA
Apache License 2.0
136 stars 36 forks source link

about sampling rate and cut off frequency #8

Closed theLearner001 closed 6 years ago

theLearner001 commented 6 years ago

Hi! Great work and very helpful.I want to use it but i don't know what to give for sampling rate and cut off frequency.i measure the Brightness of Frame and i what to use it to find the heart rate but first i want a low-pass filter.

what i want in Matlab is this

BPM_L = 40; % Heart rate lower limit [beats per minute] BPM_H = 230; % Heart rate higher limit [beats per minute] v.Framerte=30; f1=((BPM_L / 60) / v.FrameRate 2); // f1=0.01 f2=((BPM_H / 60) / v.FrameRate 2) ;// f2=0.06 [b, a] = butter(2, [f1 f2]); //the two-element vector [f1 f2], where f1 < f2, then butter designs a bandpass filter with lower cutoff frequency f1 and higher cutoff frequency f2 filtBrightness = filter(b, a, brightness);

what i have to give for sampling rate (?1) and cut off frequency (?2) in the filter you wrote? butterworth.lowPass(2,?1,?2); double butterDouble = butterworth.filter(imgAvg); // this is ok

berndporr commented 6 years ago

Your f1,f2 are normalised to Nyquist which is half the samping rate (for that reason I avoid MATLAB!). So if you want to use f1,f2 straight away then set the sampling rate to 2 in the iirj functions. butterworth.highPass(2,2,0.01); and then do a lowpass at butterworth.lowPass(2,2,0.06);