From 1a469c43d5cbf3444432ea210a84731d0e19dd26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Mon, 1 Jul 2013 16:20:19 +0200 Subject: [PATCH] optimized pixel access with explicit load() --- pysstv/color.py | 4 ++-- pysstv/grayscale.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pysstv/color.py b/pysstv/color.py index b7d56d9..29d8edd 100644 --- a/pysstv/color.py +++ b/pysstv/color.py @@ -11,12 +11,12 @@ class ColorSSTV(GrayscaleSSTV): def encode_line(self, line): cs = self.COLOR_SEQ msec_pixel = self.SCAN / self.WIDTH - image = self.image + image = self.image.load() for index in cs: for item in self.before_channel(index): yield item for col in xrange(self.WIDTH): - pixel = image.getpixel((col, line)) + pixel = image[col, line] freq_pixel = byte_to_freq(pixel[index]) yield freq_pixel, msec_pixel for item in self.after_channel(index): diff --git a/pysstv/grayscale.py b/pysstv/grayscale.py index d58d117..d793e24 100644 --- a/pysstv/grayscale.py +++ b/pysstv/grayscale.py @@ -15,9 +15,9 @@ class GrayscaleSSTV(SSTV): def encode_line(self, line): msec_pixel = self.SCAN / self.WIDTH - image = self.image + image = self.image.load() for col in xrange(self.WIDTH): - pixel = image.getpixel((col, line)) + pixel = image[col, line] freq_pixel = byte_to_freq(sum(pixel) / len(pixel)) yield freq_pixel, msec_pixel