#!/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 # In[6]: def luminance(img): # 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 = img.reshape((img.shape[0]*img.shape[1]), img.shape[2]) _img = np.multiply(_img, luminance_factors) # addiert alle Werte auf einer bestimmten Achse luminances = np.sum(_img, axis=1) return luminances