Abhisek92

Convolve_Window.py

Jun 7th, 2019
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. def get_window(index, arr, widths):
  2.     if len(index) == len(arr.shape) == len(widths):
  3.         index = np.array(index)
  4.         max_indices = np.array(arr.shape) - 1
  5.         widths = np.array(widths)
  6.         win_start = index - widths
  7.         win_end = index + widths       
  8.         win_start[win_start < 0] = 0
  9.         max_mask = win_end > max_indices
  10.         win_end = (max_mask * max_indices) + (~max_mask * win_end)
  11.         # return kernel starting from win_start to win_end instead
  12.         return  win_start, win_end
Add Comment
Please, Sign In to add comment