tobybreckon / cpp-examples-ipcv

C++ Image Processing and Computer Vision OpenCV Examples used for Teaching
GNU Lesser General Public License v3.0
27 stars 8 forks source link

Butterworth filter should have no imaginary part #2

Closed epitalon closed 1 year ago

epitalon commented 1 year ago

Line 157 in butterworth_lowpass.cpp we read Mat toMerge[] = { tmp, tmp }; I believe that we should read Mat toMerge[] = { tmp, Mat::zeros(tmp.size(), CV_32F) };

as when one multiplies a DFT image by a filter, this filter should be real only, otherwise the multiplication changes the phase along with the magnitude of each pixel in the DFT. In the current case, multiplying by {tmp, tmp} adds pi/4 to the phase in each pixel of the DFT and multiplies its magnitude by sqrt(2)*tmp.

tobybreckon commented 1 year ago

Which version of OpenCV does this against ? This master branch originally only builds against OpenCV 3.0 as of now. There is a OpenCV 4.0 branch that I'll push to main now.

tobybreckon commented 1 year ago

I have merged a version of this bug fix into the update master branch that now builds against OpenCV 4.