title: OpenCV DFT function give different between C++ and Python
body: <p>I am using the OpenCV DFT function to calculate the Fourier transform of the image and I found the different results between python code and C++ code (test with the same image).
  Following is the code snippet:</p>
  <p>C++ code:</p>
  <pre><code>Mat image = imread(&quot;sample_image_path&quot;, IMREAD_COLOR);
  float ratio = (float) image.cols / 500;
  cv::resize(image, image, cv::Size(500, (float) image.rows / ratio));
  cv::Mat frame;
  cv::cvtColor(image, frame, cv::COLOR_BGR2GRAY);
  
  cv::Mat fImage;
  frame.convertTo(fImage, CV_32F);
  
  cv::Mat fourierTransform;
  dft(fImage, fourierTransform,cv::DFT_SCALE|cv::DFT_COMPLEX_OUTPUT);
  </code></pre>
  <p>Python code:</p>
  <pre><code>image = cv2.imread(&quot;sample_image_path&quot;)
  image = imutils.resize(image, width=500)
  image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  
  image_float32 = np.float32(image)
  
  dft = cv2.dft(image_float32, flags=cv2.DFT_SCALE|cv2.DFT_COMPLEX_OUTPUT)
  </code></pre>
  <p>And these are the DFT result from those codes:
  C++ result:</p>
  <pre><code>(2.87114e+07,0)
  (-235565,-185356)
  (83053.5,-133853)
  (325047,-35144.2)
  (15266.2,73630.8)
  (10694.3,23623.2)
  (66154.5,9108.8)
  (-66126.1,31.8135)
  (-59579.2,47464.7)
  (-65894.7,-48799.3)
  (-38388.1,-34958.9)
  (11532.8,-24410.8)
  (-73011.9,-17565.3)
  (-45435.4,-59388.7)
  (-56091.8,-71480.4)
  (-58590.1,-35274.9)
  (-75216,-38256.6)
  (-47855.7,-27994)
  (-18011,-15732.5)
  </code></pre>
  <p>Python result:</p>
  <pre><code>[28730282.        0.]
  [-235971.77 -185170.42]
  [  83683.805 -134241.84 ]
  [325126.44  -34884.383]
  [14188.441 74207.67 ]
  [11826.884 23862.877]
  [66535.41   9581.168]
  [-66173.336      -88.09851]
  [-59670.54   48255.867]
  [-66266.734 -47755.05 ]
  [-38385.45 -35405.57]
  [ 11244.034 -23841.91 ]
  [-72588.35 -18074.01]
  [-45237.465 -59732.125]
  [-56079.074 -71814.05 ]
  [-59240.047 -35828.914]
  [-75450.53  -38459.656]
  [-47249.344 -28013.852]
  [-18490.021 -16484.36 ]
  ...
  </code></pre>
  <p>which is completely different
  It seems to me, that there is something wrong with DFT function.
  Any idea about why do I have this difference result between these two?</p>
  <p>Thank you in advance.</p>