title: NaN values from OpenCV dft() C++
body: <p>Hiho,</p>
  
  <p>I really cant figure out this one.</p>
  
  <p>I am using opencv 2.4.2.</p>
  
  <p>The dft()-function in the following example produces 
  an image containing at least a single NaN value
  for the last call of the compute()-function.</p>
  
  <p>When altering anything in the code, 
  even if it does not effect the dft,
  then it suddenly works.</p>
  
  <p>The code is just a minimal example of the problem 
  and part of a huge project. Some part of the code dose not make 
  any sense like this, but its just to show you the problem.</p>
  
  <p>Now the question is "Am I doing something wrong?" 
  I would expect the code to work like this.
  I attached the images in case anyone wanna try himself.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "opencv2/core/core.hpp"
  #include "opencv2/highgui/highgui.hpp"
  #include "opencv2/imgproc/imgproc.hpp"
  
  const std::vector&lt;float&gt; compute(const cv::Mat&amp; image)
  {
      cv::Mat workingImage;
      cv::Mat imgDFT;
      cv::Mat img;
  
      cv::cvtColor(image, workingImage, CV_BGR2GRAY);
      cv::resize(workingImage, img, cv::Size(256, 256));
  
      std::vector&lt;float&gt; result = std::vector&lt;float&gt;(1, 0);
      cv::copyMakeBorder(img, img, 32, 32, 32, 32, cv::BORDER_REFLECT);
      img.convertTo(img, CV_32FC1);
  
      cv::dft(img, imgDFT, cv::DFT_COMPLEX_OUTPUT);
  
      if (!cv::checkRange(imgDFT)) 
          std::cerr &lt;&lt; "NaN in imgDFT" &lt;&lt; std::endl;
  
      return result;
  }
  
  int main(int argc, char* argv[])
  {
      std::vector&lt;float&gt; descriptor0 = compute(cv::imread("1.jpg", CV_LOAD_IMAGE_COLOR));
      std::vector&lt;float&gt; descriptor1 = compute(cv::imread("1.jpg", CV_LOAD_IMAGE_COLOR));
      std::vector&lt;float&gt; descriptor2 = compute(cv::imread("2.jpg", CV_LOAD_IMAGE_COLOR));
  }
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/OcK44.jpg" rel="nofollow">http://i.stack.imgur.com/OcK44.jpg</a>    (1.jpg)
  <a href="http://i.stack.imgur.com/wBU8a.jpg" rel="nofollow">http://i.stack.imgur.com/wBU8a.jpg</a>    (2.jpg)</p>