Calculating an image's luminance histogram