From 899ffe8e9b9cda8802e6795337eafbd7fcb534dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Mon, 1 Jul 2013 23:24:26 +0200 Subject: [PATCH] cache pixel tuple length --- pysstv/grayscale.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pysstv/grayscale.py b/pysstv/grayscale.py index d793e24..7377f74 100644 --- a/pysstv/grayscale.py +++ b/pysstv/grayscale.py @@ -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