def histogram_median(histogram, image_size):
    """
    Calculates the histogram median.

    :param histogram: Histogram
    :param image_size: Image size
    :return: Histogram median
    """
    median = 0
    for i in range(0, len(histogram)):
        median += float(histogram[i]) * float(i) / float(image_size)
    return median