Loop through all pixels of 2 images and replace the black pixels with white
<p>I have 2 co-located images, both created in a similar way and both have the size of 7,221 x 119 pixels.</p>

<p>I want to loop through all the pixels of both images. If the pixels are black on the first image and also black on the second image then turn it into white, otherwise, no change.</p>

<p>How can I do it with python?</p>

<p>I suggest the use of the Pillow library (<a href="https://python-pillow.org/" rel="nofollow">https://python-pillow.org/</a>) which is a fork of the PIL library.</p>

<p>Here's something from the Pillow docs: <a href="http://pillow.readthedocs.io/en/3.1.x/reference/PixelAccess.html" rel="nofollow">http://pillow.readthedocs.io/en/3.1.x/reference/PixelAccess.html</a></p>

<p>And a couple of Stackoverflow questions that may help you:</p>

<p><a href="http://stackoverflow.com/questions/3596433/is-it-possible-to-change-the-color-of-one-individual-pixel-in-python">Is it possible to change the color of one individual pixel in Python?</a></p>

<p><a href="http://stackoverflow.com/questions/13167269/changing-pixel-color-python">Changing pixel color Python</a></p>

<p>I guess you'd just have to open both images, loop through each pixel of rach image, compare the pixels, compare pixels, then replace if necessary.</p>

python image