|
1 | | -""" Here is the challenge problem for 2d loops> |
| 1 | +""" Here is the challenge problem for 2d loops: |
2 | 2 | Images are often represented as 3d arrays, |
3 | 3 | where the rows and columns are the pixels in the image, |
4 | 4 | and each pixel has an r, g, and b value. |
|
8 | 8 | will return a different image where each pixel is the average |
9 | 9 | of the pixels surrounding it in the original image. |
10 | 10 |
|
11 | | -The neighbors of an image are all the pixels that surroun it, |
12 | | -1 on each side, and 4 on the diagonals, for 8 in total. |
13 | | -Each pixel doesn't necessarily have 8 neighbors, though (think about why) |
| 11 | +The neighbors of an image are all the pixels that surround it, |
| 12 | +1 on each side, and 4 on the diagonals, for 8 in total. Each |
| 13 | +pixel doesn't necessarily have 8 neighbors, though (think about why) |
14 | 14 |
|
15 | 15 | The code to grab an image from the internet and make it |
16 | 16 | into an array is given to you. The code also displays the new image |
|
20 | 20 | To find the average value of all of a pixels neighbors, you must |
21 | 21 | change the average of the red value to the red value, blue to blue, etc. |
22 | 22 | For example, if the neighbors of a pixel with value [1,2,3] |
23 | | -were [20,30,40] and [10,120,30], the new pixel that would replace the original one would be |
24 | | -[15,75,35] |
| 23 | +were [20,30,40] and [10,120,30], the new pixel that would replace the |
| 24 | +original one would be [15,75,35] |
25 | 25 | """ |
26 | 26 |
|
27 | 27 | from PIL import Image |
|
0 commit comments