Hi, thank you for giving this great example. That helps me a lot understanding what's going on in a filter.
I want to adopt this to create an ideal bandpass filter, according to Eq.(5.4-1), page 244, paragraph 5.4.1, Gonzalez Woods, "Digital Image Processing 2nd Edition", it can be written as following:
/**
* create_ideal_bandpass_filter - create a 2-channel ideal band-pass filter
* with radius D, order n (assumes pre-aollocated size of dft_Filter specifies dimensions)
*
* @param dft_Filter - destinate filter
* @param D - radius
* @param W - band width
*/
void create_ideal_bandpass_filter(cv::Mat &dft_Filter, int D, int W)
{
cv::Mat tmp = cv::Mat(dft_Filter.rows, dft_Filter.cols, CV_32F);
Point centre = Point(dft_Filter.rows / 2, dft_Filter.cols / 2);
double radius;
for (int i = 0; i < dft_Filter.rows; i++)
{
for (int j = 0; j < dft_Filter.cols; j++)
{
// D(u, v)
radius = (double) sqrt(pow((i - centre.x), 2.0) + pow((double) (j - centre.y), 2.0));
if (radius >= D - W/2 && radius <= D + W/2)
tmp.at<float>(i, j) = 1;
else
tmp.at<float>(i, j) = 0;
}
}
cv::Mat toMerge[] = {tmp, tmp};
merge(toMerge, 2, dft_Filter);
}
But what confuses me is that if I want to filter an image with a low cut-off frequency fl
and a high cut-off frequency fh
instead of radius D
and band width W
. For example, I want to band pass the image with fl
=0.83 and fh
=1, how to translate these two value into D and W so that I can call the above function?
I will be very grateful for your help.