Ask Your Question
0

High pass filter

asked 2018-03-29 22:21:53 -0600

julian403 gravatar image

Hello All. I hope you are doing well.

Is there a function for a high pass filter? I mean, a function which gets an array of images and a passband frecuency

I was trying to perform it getting the function from filter solution (the software) and making the discrete convolution pixel by pixel with the impulse system response and a set of ten images but it doesnt work fine at use a lot of the raspberry pi process time.

thanks in advance. regards.

edit retag flag offensive close merge delete

Comments

what are you doing there, exactly ? do you try to filter a single image spatially, or is there an image sequence, and you try to filter over time ?

"convolution pixel by pixel" -- that's always a terrible idea. please show your code.

berak gravatar imageberak ( 2018-03-30 00:56:04 -0600 )edit
1

I need to filter the image over the time with a passband frecuency of 50Hz, to get the just the movement

julian403 gravatar imagejulian403 ( 2018-03-30 07:17:29 -0600 )edit
1

High pass 50Hz = frame rate >150Hz?

LBerger gravatar imageLBerger ( 2018-03-31 02:27:54 -0600 )edit

@julian403 : https://en.wikipedia.org/wiki/Nyquist...

(doubtful, if you can get enough fps on your raspi for this)

berak gravatar imageberak ( 2018-03-31 04:36:34 -0600 )edit

I will share the code and the image output tomorrow. Due to the server doesnt allow me to answer (I have to wait to 2 days from the last post)

julian403 gravatar imagejulian403 ( 2018-03-31 10:58:07 -0600 )edit

2 answers

Sort by » oldest newest most voted
0

answered 2018-04-01 15:40:31 -0600

julian403 gravatar image

This is the code. The output its not what I wanted:

   int main(int argc,char ** argv)
{
  VideoCapture cap(0);
  if (!cap.isOpened()) {
    cerr << "ERROR: Unable to open the camera" << endl;
    return 0;
  }

  Mat frame1, frame2, frame3, frame4, frame5;
  Mat x1, x2, x3, x4, x5;

    cap >> frame1;
    usleep(3333); 
    cap >> frame2;
    usleep(3333); 
    cap >> frame3;
    usleep(3333); 
    cap >> frame4;  
    usleep(3333); 
    cap >> frame5;


frame1.convertTo(x1, CV_32S);
frame2.convertTo(x2, CV_32S);
frame3.convertTo(x3, CV_32S);
frame4.convertTo(x4, CV_32S);
frame5.convertTo(x5, CV_32S);


Mat y; 

y=0.33*x1 -0.67*x1+0.33*x2+ 0.14*x1-0.67*x2+0.33*x3 + 0.24*x1+0.14*x2-0.67*x3+0.33*x4 + 0.07*x1+0.24*x2+0.14*x3-0.67*x4+0.33*x5 -0.05*x1+0.07*x2+0.24*x3+0.14*x4-0.67*x5 - 0.05*x2+0.07*x3+0.24*x4+0.14*x5 -0.05*x3+0.07*x4+0.24*x5 - 0.05*x4+0.07*x5 - 0.05*x5; 

Mat output;

y.convertTo(output, CV_8U); 

vector<int> compression_params;
compression_params.push_back(IMWRITE_PNG_COMPRESSION);
compression_params.push_back(1);  //este valor es la compresión cuanto más alto más comprimido
imwrite("outputFilter.png", output, compression_params);
imwrite("outputWitoutFilter.png", frame1, compression_params);

And this is the image with the filter

image description

And this is the image without the filter

image description

But as It cant get and proceed the frames in continuos way and there is more than 5 discrete value in the impulse response the filter doesnt work. I will have to use the more simple filter

x1- x2

edit flag offensive delete link more

Comments

this is does not answer the question.

you should have edited your question, and put all of this there instead.

berak gravatar imageberak ( 2018-04-01 21:38:17 -0600 )edit
0

answered 2018-04-02 04:57:16 -0600

LBerger gravatar image

You can use butterwoth filter : Something like this works :

vector<double> b={0.29213704255461020,0.58427408510922041,0.29213704255461020};
vector<double> a={0,0.36952737735124142,-0.19581571265583309};
Mat frameUSB;
Mat frame;
v >> frameUSB;
frameUSB.convertTo(frame, CV_32F);
for (int i = 0; i <= 20; i++)
{
    p.x.push_back(frame.clone());
    p.y.push_back(frame.clone());
}
while (code != 27)
{
    v >> frameUSB;
    frameUSB.convertTo(frame, CV_32F);
    p.x[0] = frame.clone();
    Mat r;
    r = b[0] * p.x[0];
    for (int i = 1; i < b.size(); i++)
    {
        r += b[i] * p.x[i]; 
    }
    for (int i = 1; i < a.size(); i++)
    {
        r += a[i] * p.y[i];
    }
    for (int i = b.size() - 1; i > 0; i--)
    {
        p.x[i] = p.x[i - 1];
    }
    for (int i = a.size() - 1; i > 1; i--)
    {
        p.y[i] = p.y[i - 1];
    }
    p.y[1] = r;
    imshow(p.nomfenetre, r/256);
    code = waitKey(1);
}

Full code is here

edit flag offensive delete link more

Comments

1

Thanks That helped me because the impulse response I did use was wrong. with that IRR filter, it works (a little but it must be the raspberry due to the procceessor use goes so up)

julian403 gravatar imagejulian403 ( 2018-04-02 11:25:16 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-03-29 22:21:53 -0600

Seen: 1,376 times

Last updated: Apr 02 '18