6.6. Using an Image Library¶
Similarly, in the image processing example, we used
from image import *. That made the functions
getRed() accessible. We could also define a new function that returns a new color, or a new procedure that changes the image.
for p in pixels on line 9 let’s us loop through all of the pixels in the image and change the red value for each pixel. We’ll talk more about looping (repeating steps) in the next chapter.
This ability to name functions and procedures, and sets of functions and procedures, and absolutely anything and any set of things in a computer is very powerful. It allows us to create abstractions that make the computer easier to program and use. More on that in a future chapter.
Discuss topics in this section with classmates.