Change the image background colour to white?
<p>I have a set of images which is basically the optical flow of images.</p>
<p>The code for the optical flow was taken from <a href="http://docs.opencv.org/master/d7/d8b/tutorial_py_lucas_kanade.html" rel="nofollow noreferrer">this post.</a>
I have used the Dense Optical Flow in OpenCV.</p>
<p>I would like to convert the images from a black background to a white one.</p>
<p><a href="https://i.stack.imgur.com/QF56u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QF56u.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/NzApd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NzApd.png" alt="enter image description here" /></a></p>
<p>This is what I have have now but I feel its not an actual transformation.
Any way I could keep the same amt of info ? Although makiing the 30 to 1 would keep all info same. I feel it has too much extra info (small movement also saved)
any thoughts ?</p>
<pre><code>import cv2
import os
import sys
import numpy as np

img1='/home/anilil/Downloads/1.png'
im = cv2.imread(img1,1)
im [im&lt;30]=254

cv2.imshow('abc',im)
cv2.waitKey(10000)
cv2.destroyAllWindows()
</code></pre>
<p>Varying the 30 in the <code>im [im&lt;30]=254</code> to other values gives several diff images.</p>
<h1>Output images</h1>
<p><a href="https://i.stack.imgur.com/NYGdC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NYGdC.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/pyvyH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pyvyH.png" alt="enter image description here" /></a></p>