Using for loops#
Now, suppose we have a 3x3 grid of pixels that is represented by a 2D list. Let’s suppose we take your red_filter_pixel()
function, and apply it to each of the pixels in a 3x3 image. Which of the following nested for loops will properly produce the following result, assuming our 2D list is called img
?
Here’s our initial img
:
(255,128,128) (5,100,200) (255,128,128)
(100,5,200) (255,128,128) (100,5,200)
(255,128,128) (5,100,200) (255,128,128)
and here is it after having the nested for loop applied:
(255,0,0) (5,0,0) (255,0,0)
(100,0,0) (255,0,0) (100,0,0)
(255,0,0) (5,0,0) (255,0,0)