Skip to content

Commit

Permalink
Add comments, fix small bug
Browse files Browse the repository at this point in the history
The bug was that the averages were slightly off because I forgot to set y_relative_indexes to an empty list (which I now did, which is why it's now fixed)
  • Loading branch information
chrehall68 committed Aug 9, 2021
1 parent 948c7c0 commit 233c2d5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions 2_intermediate/chapter10/solutions/img_avg.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ def distort(original_image, new_image):
original_image (list or tuple) - the reference image.
new_image (list) - the image to modify.
"""
DISTORTION_RADIUS = 1
DISTORTION_RADIUS = 1 # this should be a positive integer
# Note that each increase of DISTORTION_RADIUS increases
# run time amazingly. Slower PC's should stick to values like
# 1 or 2 for DISTORTION_RADIUS

for row in range(len(original_image)):
for column in range(len(original_image[0])):
# we set these to empty lists because the for loops
# will iterate through all valid relative indexes
# (including 0) and append them to these lists.
x_relative_indexes = []
y_relative_indexes = [0]
y_relative_indexes = []

# handle y relative indexes
# +1 to DISTORTION_RADIUS because stop is exclusive
Expand Down

0 comments on commit 233c2d5

Please sign in to comment.