Skip to content

Commit

Permalink
bugfix: motion blur works on arbitrarily small images
Browse files Browse the repository at this point in the history
  • Loading branch information
Hvitgar committed Oct 30, 2019
1 parent 4acffd8 commit 94aaac4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions imagecorruptions/corruptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ def _motion_blur(x, radius, sigma, angle):
for i in range(width):
dx = -math.ceil(((i*point[0]) / hypot) - 0.5)
dy = -math.ceil(((i*point[1]) / hypot) - 0.5)
if (np.abs(dy) >= x.shape[0] or np.abs(dx) >= x.shape[1]):
# simulated motion exceeded image borders
break
shifted = shift(x, dx, dy)
blurred = blurred + kernel[i] * shifted

return blurred


# /////////////// End Corruption Helpers ///////////////


Expand Down

0 comments on commit 94aaac4

Please sign in to comment.