Ask Your Question
0

How to implement a butterworth filter in OpenCV

asked 2015-11-06 15:03:54 -0600

215 gravatar image

updated 2015-11-07 01:20:58 -0600

I want to implement a function which takes an image, and apply a bandpass butter worth filter on to it, but can not seem to figure out how using OpenCV shall compute the DFT of an image, and apply a filter onto it .

Some form of help would be helpful here..

My implementation of

Mat bandpass(double d0, double n, int wy, int wx, int cx, int cy)
        {
            cv::Mat_<cv::Vec2f> pf(wy, wx);
            for(int y = 0; y < wy; ++y) {
                for(int x = 0; x < wx; ++x) {
                    // Real part
                    for(int i = 0; i < 3 ; i++)
                    {
                        const double d = std::sqrt( double((x-cx)*(x-cx)) + double((y-cy)*(y-cy)) );
                        const double d_k = std::sqrt(pow(x-cx-(cx+100),2.0) + pow(y-cy-(cy+100),2.0));
                        const double d_mk = std::sqrt(pow(x-cx+(cx+0),2.0) + pow(y-cy+(cy+0),2.0));
                        if(d==0) // Avoid division by zero
                            pf(y,x)[0] = 0;
                        else
                            //  pf(y,x)[0] = 1.0 / (1.0 + std::pow(d0/d, 2.0*n));
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-11-06 19:03:51 -0600

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-11-06 15:03:54 -0600

Seen: 6,830 times

Last updated: Nov 07 '15