docs: def add_layer2image_int(grid2d, x_pos, y_pos, kernel):
      """
      adds a kernel on the grid2d image at position x_pos, y_pos at integer positions of pixel
      :param grid2d: 2d pixel grid (i.e. image)
      :param x_pos: x-position center (pixel coordinate) of the layer to be added
      :param y_pos: y-position center (pixel coordinate) of the layer to be added
      :param kernel: the layer to be added to the image
      :return: image with added layer
      """
      nx, ny = np.shape(kernel)
      if nx % 2 == 0:
          raise ValueError("kernel needs odd numbers of pixels")
  
      num_x, num_y = np.shape(grid2d)
      x_int = int(round(x_pos))
      y_int = int(round(y_pos))
  
      k_x, k_y = np.shape(kernel)
      k_l2_x = int((k_x - 1) / 2)
      k_l2_y = int((k_y - 1) / 2)
  
      min_x = np.maximum(0, x_int-k_l2_x)
      min_y = np.maximum(0, y_int-k_l2_y)
      max_x = np.minimum(num_x, x_int+k_l2_x + 1)
      max_y = np.minimum(num_y, y_int+k_l2_y + 1)
  
      min_xk = np.maximum(0, -x_int + k_l2_x)
      min_yk = np.maximum(0, -y_int + k_l2_y)
      max_xk = np.minimum(k_x, -x_int + k_l2_x + num_x)
      max_yk = np.minimum(k_y, -y_int + k_l2_y + num_y)
      if min_x >= max_x or min_y >= max_y or min_xk >= max_xk or min_yk >= max_yk or (max_x-min_x != max_xk-min_xk) or (max_y-min_y != max_yk-min_yk):
          return grid2d
      kernel_re_sized = kernel[min_yk:max_yk, min_xk:max_xk]
      new = grid2d.copy()
      new[min_y:max_y, min_x:max_x] += kernel_re_sized
      return new