def scene_element_slicer(r_i, c_i, scene_element_position_dict, scene_element_dimension, as_slice=False):
    """
    Returns the starting and ending row and column indices needed to slice pixels from a scene element.

    Parameters
    ----------
    r_i
        Scene element row
    c_i
        Scene element column
    scene_element_position_dict
        Lookup table
    scene_element_dimension
        Size of scene element
    as_slice
        Whether to return as an actual slice, or just the start/end indices

    Returns
    -------
    row, col slices
    """
    dx = scene_element_dimension // 2
    row, col = scene_element_position_dict[r_i, c_i]
    r1, r2 = int(row) - dx, int(row) + dx + 1
    c1, c2 = int(col) - dx, int(col) + dx + 1
    if as_slice:
        return slice(r1, r2), slice(c1, c2)
    else:
        return r1, r2, c1, c2