-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevel23.py
More file actions
20 lines (13 loc) · 1.04 KB
/
level23.py
File metadata and controls
20 lines (13 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Last night you partied a little too hard. Now there's a blaccol and white photo of you that's about to go viral! You can't let this ruin your reputation, so you want to apply the box blur algorithm to the photo to hide its content.
# The pixels in the input image are represented as integers.
# The algorithm distorts the input image in the following way:
# Every pixel x in the output image has a value equal to the average value of the pixel values from the 3 × 3 square that has its center at x, including x itself. All the pixels on the border of x are then removed.
# Return the blurred image as an integer, with the fractions rounded down.
def solution(image):
mat_n = []
for row in range(1, len(image)-1):
mat_n.append([])
nest = mat_n[row-1]
for col in range(1, len(image[row])-1):
nest.append(((image[row-1][col-1])+(image[row-1][col])+(image[row-1][col+1])+(image[row][col-1])+(image[row][col])+(image[row][col+1])+(image[row+1][col-1])+(image[row+1][col])+(image[row+1][col+1]))//9)
return mat_n