How to implement a butterworth filter in OpenCV
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));