def scale_bbox(bbox, scalefactor):
    """
    Increase or decrease given bounding box by the scalefactor.

    Parameters
    ----------
    bbox: tuple
          tuple of integers defining coordinates of the form
          (x1, y1, x2, y2, x3, y3, x4, y4).
    scalefactor: float
                 factor of the scaling.
                 To reduce the bbox by half, scalefactor should be 0.5.
    """
    xc = (bbox[0] + bbox[4]) / 2
    yc = (bbox[1] + bbox[5]) / 2
    new_w = (bbox[4] - bbox[0]) * scalefactor
    new_h = (bbox[5] - bbox[1]) * scalefactor
    x1 = xc - new_w / 2
    y1 = yc - new_h / 2
    x2 = xc + new_w / 2
    y2 = yc - new_h / 2
    x3 = xc + new_w / 2
    y3 = yc + new_h / 2
    x4 = xc - new_w / 2
    y4 = yc + new_h / 2
    return (x1, y1, x2, y2, x3, y3, x4, y4)