title: OpenCV error using inverse
body: <p>I'm working SIFT implementation using Visual C++. My code throws an error while taking inverse:</p>
  
  <pre><code>/// Load the source image    
  src = imread("C:/Users/Adithyaanirudhha/Documents/Visual Studio 2015/Projects/ConsoleApplication2/pa.jpg", 1);
  
  if (display_caption("Original Image") != 0) { return 0; }
  
  dst = src.clone();
  width = src.size().width;
  height = src.size().height;
  Size size(height,width);
  if (display_dst(DELAY_CAPTION) != 0) { return 0; }
  cvtColor(src, src, CV_RGB2GRAY);
  /// Applying Gaussian blur
  
  
  //for(int j=0;j&lt;4;j++)
  //{
  //resize(src, src, size / 2);
  k = 2 ^ (1 / 2);
  for(int i=0;i&lt;3;i++)
  {
  //if (display_caption("Gaussian Blur") != 0) { return 0; }
  GaussianBlur(src, dst, Size(), 1.6*k, 1.6*k);
  if (display_dst(DELAY_BLUR*10) != 0) { return 0; }
  k = k * k;
  dst.copyTo(dest[m]);
  //dest[m] = dst;
  m++;
  }
  //}
  
  width2 = dog[1].size().width;
  height2 = dog[1].size().height;
  Size sizes(width2,height2);
  Mat dog_inv(sizes,0,CV_64F);
  for (int n = 0; n &lt; 2; n++)
  {
      if(m1!=3 || m1 != 6 || m1 != 9)
      subtract(dest[m1 + 1], dest[m1], dog[n],noArray(),-1);
  }
  for (int i = 0; i &lt; 2; i++)
  {
      Sobel(dog[i], grad_x, CV_16S, 1, 0, 3, 1, 0, BORDER_DEFAULT);
      convertScaleAbs(grad_x, grad_x);
      transpose(grad_x, temp);
      Sobel(dog[i], grad_x_2, CV_16S, 2, 0, 3, 1, 0, BORDER_DEFAULT);
      convertScaleAbs(grad_x_2, grad_x_2);
      c = invert(dog[i],dog_inv, DECOMP_LU);
  
      Sobel(dog[i], grad_x_2_1, CV_16S, 2, 0, 3, 1, 0, BORDER_DEFAULT);
      convertScaleAbs(grad_x_2_1, grad_x_2_1);
      //imshow(window_name,src);
      //grad_x_2_1 = grad_x_2_1.inv(CV_32F);
      multiply(grad_x_2_1, grad_x, x_max, 1, 1);
      multiply(temp, x_max, p1, 1, 1);
      transpose(x_max,temp);
      //multiply(temp, grad_x_2, p2, 1, 1);
      multiply(p2, x_max, p2, 1, 1);
      imshow(window_name, dog[1]);
      /*for (int y = 0; y &lt; dog[i].rows; y++)
      {
          for (int x = 0; x &lt; dog[i].cols; x++)
          {
              dog[i].at&lt;Vec3b&gt;(y, x) = (-1 * (p1.at&lt;Vec3b&gt;(y, x)) + 0.5*(p2.at&lt;Vec3b&gt;(y, x)) + dog[i].at&lt;Vec3b&gt;(y, x));
          }
      }*/
      //imshow(window_name, dog[1]);
      //imshow(window_name, src);
  </code></pre>
  
  <p>and the error is:</p>
  
  <blockquote>
    <p>OpenCV Error: Assertion failed (type == CV_32F || type == CV_64F) in cv::invert,
     file C:\buildslave64\win64_amdocl\master_PackSlave-win64-vc14-shared\opencv\mod
    ules\core\src\lapack.cpp, line 798
    Press any key to continue . . .</p>
  </blockquote>