def find_histogram_range(histogram):
    """
    Find the min and max index where histogram value is larger than zero.

    :param histogram: A histogram, e.g. an output of cv.calcHist().
    :returns: The min and max index with larger-than-zero value
    """
    size = len(histogram)
    min_i = 0
    while min_i < size:
        if histogram[min_i] > 0:
            break
        min_i += 1

    max_i = size - 1
    while max_i >= 0:
        if histogram[max_i] > 0:
            break
        max_i -= 1
    return min_i, max_i