Skip to content

Commit 2999398

Browse files
author
Marco Dalla Vecchia
committed
updated shape reference for non-squared images
1 parent 3bda9ee commit 2999398

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

episodes/files/source-code/blur-animation/create_blur_animation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def update(frame):
4848
- Update blurred image frame
4949
"""
5050
pbar.update(1)
51-
row = (frame % total_frames) // (img_pad.shape[1] - kernel_size + 1)
51+
row = (frame % total_frames) // (img_pad.shape[0] - kernel_size + 1)
5252
col = (frame % total_frames) % (img_pad.shape[1] - kernel_size + 1)
5353

5454
k_rect.set_x(col - 0.5)
@@ -93,7 +93,7 @@ def update(frame):
9393
# precompute animation frames and append to the list
9494
total_frames = (img_pad.shape[0] - kernel_size + 1) * (img_pad.shape[1] - kernel_size + 1) # total frames if by change image is not squared
9595
for frame in range(total_frames):
96-
row = (frame % total_frames) // (img_pad.shape[1] - kernel_size + 1) # row index
96+
row = (frame % total_frames) // (img_pad.shape[0] - kernel_size + 1) # row index
9797
col = (frame % total_frames) % (img_pad.shape[1] - kernel_size + 1) # col index
9898
img_chunk = img_pad[row : row + kernel_size, col : col + kernel_size] # get current image chunk inside the kernel
9999
new_img[row, col] = np.mean(img_chunk).astype(np.uint16) # calculate its mean -> mean filter
@@ -121,7 +121,7 @@ def update(frame):
121121
# Fix limits to the right image (without padding) is the same size as the left image (with padding)
122122
ax2.set(
123123
ylim=((img_pad.shape[0] - kernel_size / 2), -kernel_size / 2),
124-
xlim=(-kernel_size / 2, (img_pad.shape[0] - kernel_size / 2))
124+
xlim=(-kernel_size / 2, (img_pad.shape[1] - kernel_size / 2))
125125
)
126126

127127
# We don't need to see the ticks

0 commit comments

Comments
 (0)