Returns bounding box in slicing-friendly format (i-min, i-xmax, j-min, j-max, k-min, k-max).
    The fourth and fifth items are returned only if input image is 3D.
    Parameters
    ----------
    im - input binary image

    Returns
    -------
    indices - (i-min, i-xmax, j-min, j-max, k-min, k-max) in 3D case, (i-min, i-xmax, j-min, j-max) in 2D case.

def get_bbox(im):
    '''
    Returns bounding box in slicing-friendly format (i-min, i-xmax, j-min, j-max, k-min, k-max).
    The fourth and fifth items are returned only if input image is 3D.
    Parameters
    ----------
    im - input binary image

    Returns
    -------
    indices - (i-min, i-xmax, j-min, j-max, k-min, k-max) in 3D case, (i-min, i-xmax, j-min, j-max) in 2D case.
    '''
    coords = np.nonzero(im)
    inds = []
    for i in coords:
        i_min = i.min()
        i_max = i.max()
        inds.extend((i_min, i_max))

    return inds