title: Sliding window iteration over numpy array
body: <p>i am filtering out the max and min value in each sliding window. the sliding window is of array size 27x27. the shape of the entire array is 939 x1271..the problem is if i use this code for larger array 24000x40000 size it only filters 24000x24000 rest remain blank.</p>
  <pre><code>def calculate_raster(width, height, index, filter_size, raster_arr, raster_layer, llidt, count): 
  i, j  = index
  start_x, end_x = i, np.min([width,i+filter_size[0]])
  start_y, end_y = j, np.min([height,j+filter_size[0]])
  elevation_array = arr[start_x:end_x, start_y:end_y]
  max_idx, min_idx = np.unravel_index(np.argmax(elevation_array, axis=None), elevation_array.shape), np.unravel_index(np.argmin(elevation_array, axis=None), elevation_array.shape)
  global_max_idx = tuple( np.array(max_idx) + [start_x, start_y])
  global_min_idx = tuple( np.array(min_idx) + [start_x, start_y])
  diff = elevation_array[max_idx] - elevation_array[min_idx]
  if  diff &gt;= 300:
      count=count+1
  raster_arr[global_min_idx] = elevation_array[min_idx]
  raster_arr[global_max_idx] = elevation_array[max_idx]
  raster_layer[global_min_idx] = 1
  raster_layer[global_max_idx] = 2
  llidt=()
  # llidt.append([global_min_idx, max_idx])
  return llidt,raster_arr,raster_layer
  </code></pre>