def expand_box(box, img_shape, scale=None, padding=None):
    """Expand roi box

    Parameters
    ----------
    box : list
        [x, y, w, h] order.
    img_shape : list
        [width, height]
    scale : float, optional
        Expand roi by scale, by default None
    padding : int, optional
        Expand roi by padding, by default None

    Returns
    -------
    expanded roi: list
        [x, y, w, h] order.
    """
    x, y, w, h = box
    wmax, hmax = img_shape

    if scale is not None:
        xo = max([x - (scale - 1) * w / 2, 0])
        yo = max([y - (scale - 1) * h / 2, 0])
        wo = w * scale
        ho = h * scale
    elif padding is not None:
        xo = max(x - padding, 0)
        yo = max(y - padding, 0)
        wo = w + padding * 2
        ho = h + padding * 2
    else:
        xo, yo, wo, ho = x, y, w, h

    if xo + wo >= wmax:
        wo = wmax - xo - 1
    if yo + ho >= hmax:
        ho = hmax - yo - 1

    return [int(xo), int(yo), int(wo), int(ho)]