ich möchte die relative Helligkeit eines Kanals in einem QImage berechnen, dazu habe ich mir folgende Funktion geschrieben:
Code: Alles auswählen
def calculate_brightness(self, image):
width, height = image.size().width(), image.size().height()
maximum = width*height*255
total = 0
for row in xrange(height):
for column in xrange(width):
pixel = image.pixel(column, row)
color = QtGui.QColor(pixel)
total += color.red()
return total/maximum

Code: Alles auswählen
line_pointer = image.scanLine(row)
Grüße,
anogayales