cache pixel tuple length

This commit is contained in:
András Veres-Szentkirályi 2013-07-01 23:24:26 +02:00
parent f0a2076a68
commit 899ffe8e9b

View file

@ -16,9 +16,10 @@ class GrayscaleSSTV(SSTV):
def encode_line(self, line):
msec_pixel = self.SCAN / self.WIDTH
image = self.image.load()
pixlen = len(image[0, line])
for col in xrange(self.WIDTH):
pixel = image[col, line]
freq_pixel = byte_to_freq(sum(pixel) / len(pixel))
freq_pixel = byte_to_freq(sum(pixel) / pixlen)
yield freq_pixel, msec_pixel