def _subimg_bbox(img, subimage, xc, yc):
    """
    Find the x/y bounding-box pixel coordinates in ``img`` needed to
    add ``subimage``, centered at ``(xc, yc)``, to ``img``.  Returns
    ``None`` if the ``subimage`` would extend past the ``img``
    boundary.
    """

    ys, xs = subimage.shape
    y, x = img.shape
    y0 = int(yc - (ys - 1) / 2.0)
    y1 = y0 + ys
    x0 = int(xc - (xs - 1) / 2.0)
    x1 = x0 + xs
    if (x0 >= 0) and (y0 >= 0) and (x1 < x) and (y1 < y):
        return (x0, x1, y0, y1)
    else:
        return None