6.3 Basic Image Processing

We now have all the tools necessary to do some simple image processing. Our first examples will perform color manipulations on an image. In other words, we want to take the existing pixels and modify them in some way to change the appearance of the original image. The basic idea will be to systematically process each pixel one at a time and perform the following operations:

  1. Extract the color components.

  2. Build a new pixel.

  3. Place that pixel in a new image at the same location as in the original.

Once we see the general pattern, our options for image processing are endless. Note that all of the newly constructed images in this section will have the same dimensions as the original image.

6.3.1 Negative Images

Get Python Programming in Context, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.