Our Head of Physics today asked me if there was any code we could use that would demonstrate to his A-Level Physics students the way that digital images are represented by red, green and blue pixels with a value between 0 and 255. The reason is because of the introduction of a digital imaging unit within the new A-Level specification, and whilst this could be taught as pure theory he felt a working example to illustrate the point might help.
This got me thinking and after a bit of searching I found a Stack Overflow post which gave an example of retrieving a single pixel’s RGB value and printing it out.
This example makes use of the PIL python library, which unfortunately has not been updated for Python 3. However we can make use of the Pillow library in Python 3 to achieve the same thing!