title: Mean Absolute Error - Python
body: <p>I'm new to Python</p>
  
  <p>I have to implement a function that can calculate MAE between 2 images</p>
  
  <p>Here is the MAE formula i have learnt:<a href="https://i.stack.imgur.com/Qegha.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Qegha.png" alt="enter image description here"></a></p>
  
  <p>Here is my code:</p>
  
  <pre><code>def calculateMAE(imageA, imageB):
      """
      Calculate MAE between 2 images
      np: numpy
  
      """
      mae = np.sum(imageB.astype("float") - imageA.astype("float"))
      mae /= float(imageA.shape[0] * imageA.shape[1] * 255) 
  
      if (mae &lt; 0):
          return mae * -1
      else:
          return mae
  </code></pre>
  
  <p>Can anyone tell me if my function is right?
  Thanks in advance!</p>