title: Calculate MSE of two images
body: <p>I'm trying to calculate the MSE of two images using the following code:-</p>
  
  <pre><code>void getMSE(const Mat&amp; I1, const Mat&amp; I2)
  {
  Mat s1;
  absdiff(I1, I2, s1);       // |I1 - I2|
  s1.convertTo(s1, CV_32F);  // cannot make a square on 8 bits
  s1 = s1.mul(s1);           // |I1 - I2|^2
  
  Scalar s = sum(s1);        // sum elements per channel
  
  double sse = s.val[0] + s.val[1] + s.val[2]; // sum channels
  
  
      double mse  = sse / (double)(I1.channels() * I1.total());
  
      printf("mse = %f", mse);
  
   }
  </code></pre>
  
  <p>It's not running successfully and I was wondering if you guys had any idea? Would this code not run if the image sizes were different? VS10 says I have a runtime error, which is vague to say the least!</p>
  
  <p>Many thanks in advance</p>