low pass filter coefficients
In MATLAB, there is a command fir1 that generates the filter coefficients but how to calculate low pass filter's coefficients in OpenCV? I need to use a low pass filter with 50th order, hamming window and cutoff frequency = 0.00000000001. Also, I can't use filter2D command because I'm doing 1D filtering just like low pass filtering of an audio signal (example).
just curious, what are you trying to do ? (1d arrays are a rare thing in opencv)
how would you apply that fir filter ?
given 20 coefs, for each 'pixel', it's probably just the dot product of the last 20 values with the coefs array ?
I'm actually working on the stabilization of panoramic videos. The code is actually first written in MATLAB and now, I need to convert that code into OpenCV first in order to proceed further and do all my work in OpenCV for using its provided files later.
Now, actually, in MATLAB "fir1" command designs a filter and returns the filter coefficients. For that command the above mentioned parameters were used. When it is designed, then the "filter" command is used to apply the low pass filter on the data. For filter command, I've to pass the rows in data as vector (1 row and multiple columns), numerator as filter coefficients and denominator as 1. This gives me the filtered data as an output of 'filter' command
can you give a (smallish) example, so folks here can try to reproduce it ?
Its just like filtering 1D voice signal. The filter will slide over the 1 D data and we continue storing the data for each filtering effect.
For example, if I have to first design a low pass filter (using hamming window cutoff frequency and order = 5 or length =5+1=6) then the "filt" command will generate the following six filter coefficients: [0.02877 0.14311 0.32811 0.3281 0.14311 0.02877] Now, if the size of my data is 26x26 then I should append some zeros in the output matrix (number of appended zeros will be equal to the filter length) and now, I will get the size of output matrix as 26x(26+6) or 26x32.
For applying this filter, there will be a loop starting from 1 to 26. Inside this loop, "filter" command will be used that will take filter co-efficient as nominator, 1 as denominator and one row of 26x26 data). In this way, each row of 26x26 data will be processed and in this way, each row of the 26x26 data will be processed. The output will be stored in the rows of the output matrix (26x32), one after the other row, on each iteration of this loop.
I don't think there's a function to calculate the coefficients, but the functions to apply it are there. A SepFilter2D with the vertical set to a 1x1 matrix containing 1 would likely be the best way. You can use the anchor parameter cv::Point(0,0) to set it all the way to the side (I think that's right, you'd want to test it.)
About filter coefficients there is a library here Do you want to filter your video in time or space?
@LBerger in time..
I f size image is 200X200 pixels and your filter is of size 5 it means you will have to filter 40000 signal of size 5. I will do it like this (gray image):
May be you shoulduse an IIR filter