#!/usr/bin/env python # -*- coding: utf-8 -*- import numpy as np def timelabels(val, pos): min, sec = divmod(int(val), 60) timelabel = "{0}:{1:02d}".format(min, sec) return timelabel def luminance(img): """Creates an array of luminance value for each pixel of an image The array has the same dimensions as the image. However the third does only have the size 1 which contains the luminance value """ # Luminance Faktoren nach http://introcs.cs.princeton.edu/python/31datatype/luminance.py.html luminance_factors = np.array([.299, .587, .114]) # Erzeugung eines eindimensionalen Arrays für die effizientere Berechnung img = np.multiply(img, luminance_factors) # addiert alle Werte auf einer bestimmten Achse luminances = np.sum(img, axis=2) return luminances