Determine the exposure of a photo, which can be under-exposed,
    normally exposed or over-exposed.


    @param image: a Python Library Image (PIL) object to determine the
        exposure.

    @param filters: a list of ``ColorComponentFilter`` filter or ``None``
        to use all the filters.


    @return: an ``ExposureStatus`` instance that represents the exposure
             of the given PIL object.

def get_exposure(image, filters=None):
    """
    Determine the exposure of a photo, which can be under-exposed,
    normally exposed or over-exposed.


    @param image: a Python Library Image (PIL) object to determine the
        exposure.

    @param filters: a list of ``ColorComponentFilter`` filter or ``None``
        to use all the filters.


    @return: an ``ExposureStatus`` instance that represents the exposure
             of the given PIL object.
    """
    def _get_exposure(histogram):
        total = sum(histogram)
        range_offset = len(histogram) / 4
        dark = float(sum(histogram[0:range_offset])) / total
        #normal = float(sum(histogram[range_offset:-range_offset])) / total
        light = float(sum(histogram[-range_offset:])) / total
        return PictureExposure.UnderExposed if dark > 0.5 and light < 0.5 \
            else PictureExposure.OverExposed if dark < 0.5 and light > 0.5 \
            else PictureExposure.NormallyExposed

    FILTER_SETTINGS = {
        ColorComponentFilter.Red: ('RGB', 0, 256),
        ColorComponentFilter.Green: ('RGB', 256, 512),
        ColorComponentFilter.Blue: ('RGB', 512, 768),
        ColorComponentFilter.Grey: ('L', 0, 256)
    }

    exposures = collections.defaultdict(int)
    for exposure in [ _get_exposure(image.convert(mode).histogram()[start_index:end_index])
        for (mode, start_index, end_index) in [ FILTER_SETTINGS[filtr]
            for filtr in filters or [
                ColorComponentFilter.Red,
                ColorComponentFilter.Green,
                ColorComponentFilter.Blue,
                ColorComponentFilter.Grey
            ] ] ]:
        exposures[exposure] += 1

    return sorted(exposures.iterkeys(), key=lambda k: exposures[k], reverse=True)[0]