Python, OpenCV: Increasing image brightness without overflowing UINT8 array
<p>I am trying to increase brightness of a grayscale image. <code>cv2.imread()</code> returns a numpy array. I am adding integer value to every element of the array. Theoretically, this would increase each of them. After that I would be able to put upper threshold of 255 and get the image with the higher brightness.</p>
<p>Here is the code:</p>
<pre><code>grey = cv2.imread(path+file,0)

print type(grey)

print grey[0]

new = grey + value

print new[0]

res = np.hstack((grey, new))

cv2.imshow('image', res)
cv2.waitKey(0)
cv2.destroyAllWindows()
</code></pre>
<p>However, numpy addition apparently does something like that:</p>
<pre><code>new_array = old_array % 256
</code></pre>
<p>Every pixel intensity value higher than 255 becomes a remainder of dividing by 256.</p>
<p>As a result, I am getting dark instead of completely white.</p>
<p>Here is the output:</p>
<pre><code>&lt;type 'numpy.ndarray'&gt;
[115 114 121 ..., 170 169 167]
[215 214 221 ...,  14  13  11]
</code></pre>
<p>And here is the image:</p>
<p><a href="https://i.stack.imgur.com/ysOjn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ysOjn.jpg" alt="enter image description here" /></a></p>
<p>How can I switch off this remainder mechanism? Is there any better way to increase brightness in OpenCV?</p>