title: OpenCV/Python: Error in cv2.add() to add a number to image
body: <p>I'm using OpenCV/Python and I'm trying to add a number to image.</p>
  
  <p>My code is:</p>
  
  <pre><code>import cv2
  import numpy as np
  import math
  from matplotlib import pyplot as plt
  
  img = cv2.imread('messi.jpg',0)
  img2 = img
  img2 = cv2.add(img2, np.uint8([50]))
  </code></pre>
  
  <p>I got the next error:</p>
  
  <pre><code>OpenCV Error: Assertion failed (type2 == CV_64F &amp;&amp; (sz2.height == 1 || sz2.heigh
  t == 4)) in cv::arithm_op, file C:\builds\master_PackSlaveAddon-win64-vc12-stati
  c\opencv\modules\core\src\arithm.cpp, line 1989
  Traceback (most recent call last):
    File "lab3_examples.py", line 27, in &lt;module&gt;
      img2 = cv2.add(img, np.uint8([50]))
  cv2.error: C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\core
  \src\arithm.cpp:1989: error: (-215) type2 == CV_64F &amp;&amp; (sz2.height == 1 || sz2.h
  eight == 4) in function cv::arithm_op
  </code></pre>
  
  <p>The image I'm using is <code>messi.jpg</code> <a href="https://i.stack.imgur.com/6QscS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6QscS.jpg" alt="enter image description here"></a></p>
  
  <p>Instead, if I use <code>img2 = np.add(img2, np.uint8([50]))</code> intensities that pass the value 255 the <code>value % 255 result</code>, e.g. <code>260%255=4</code> the pixel's value is set to 4 instead of 255. As a result, white pixels are turned to black!</p>
  
  <p>Here is the faulty resulted image. <a href="https://i.stack.imgur.com/ecAyd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ecAyd.png" alt="enter image description here"></a></p>
  
  <p>Any ideas please?</p>