def get_checkbox_crop(img, rect, border_crop_factor=0.15):
    """
    Takes in image as `numpy.ndarray` and rectangle to be cropped out and returns the cropped out image.

    Args:
        img (numpy.ndarray):
            Image as numpy array.
        rect (list, tuple or array):
            Rectangle from OpenCV with following values: `(x, y, width, height)`
        border_crop_factor (float, optional):
            Defines how much from the image border should be removed during cropping.
            This is used to remove any leftovers of checkbox frame.
            Defaults to 0.15.

    Returns:
        numpy.ndarray:
            Image crop as numpy array.
    """ # NOQA E501
    # collect base parameters of the crop
    width = rect[2]
    height = rect[3]
    x1 = rect[0]
    y1 = rect[1]
    x2 = x1 + width
    y2 = y1 + height

    # calculate horizontal and vertical border to be cropped
    w_pad = int(width * border_crop_factor)
    h_pad = int(height * border_crop_factor)

    # crop checkbox area from original image
    im_crop = img[y1 + h_pad:y2 - h_pad, x1 + w_pad:x2 - w_pad]

    return im_crop