I would like to try to filter out periodic noise from some images using Fourier Transform. The resulting images have different brightness levels after dft > idft even if i dont filter anything out. I asked my teacher from university about that and he says this shouldn’ happen and i probably have something wrong with my code.
Simple code:
#include <opencv2/opencv.hpp>
int main() {
cv::Mat image = cv::imread(“0.BMP”, cv::IMREAD_GRAYSCALE);
Some images get darker, some lighter and some don’t change their brightness.
I have also tried that with FFTW library and it does the same but i was using cv::normalize() there too.
The brightness can be restored by means of other opencv functions but the images i would like to filter out are for phase calculation (fringe patterns) and any change in brightness results in faulty phase so i don’t want to mess with them too much.
So is this how DFT works or maybe something with the normalize() function?
did he actually look at your code, or did he just hypothesize?
what do you think that line does?
why do you do it?
send him my regards. I want five minutes’ worth of his salary, or a beer, if I ever find out who he is.
to answer the question: roundtripping with fourier transforms will need scaling. given the right coefficients, the whole thing roundtrips nicely. OpenCV’s functions have a flag for this scaling. please skim the docs for these functions.
No I didn’t show him my code as he is an optics teacher not IT. He only proposed Fourier transform as a filtering method and all the wrong-doing is on my side.
As in the first post i have suspected the whole problem may be connected to the normalize function.
Anyway should i not use the normalize() at all and find another flags for the forward and backward Fourier transform or use the normalize() but just with another flags?
I will search through the docs again.
Thank you
EDIT: after reading your answer 10 more times i think i dont need normalize() at all, just different DFT flags.
NORM_MINMAX simply finds the min and max of the data and scales those to the limits. that will cause the entire operation to depend strongly on the data, which is not what you want. you want it to operate independently of the data.