def pyramid(image, scale=2, min_size=(30, 30), inter=None):
    """
    Creates generator of image pyramid.
    :param image: input image
    :param scale: factor that controls by how much the image is resized at each layer
    :param min_size: minimum required width and height of the layer
    :return: generator of the image pyramid
    """
    yield image
    import cv2
    if inter is None:
        inter=cv2.INTER_AREA
    # yield the original image

    # keep looping over the pyramid
    while True:
        # compute the new dimensions of the image and resize it
        w = int(image.shape[1] / scale)
        image = resize(image, width=w, inter=inter)

        # if the resized image does not meet the supplied minimum
        # size, then stop constructing the pyramid
        if image.shape[0] < min_size[1] or image.shape[1] < min_size[0]:
            break

        # yield the next image in the pyramid
        yield image