mirror of
https://github.com/dnet/pySSTV.git
synced 2025-12-06 07:12:00 +01:00
GrayscaleSSTV: use PIL for grayscale conversion
This commit is contained in:
parent
bd3b84cfb6
commit
b74feb49ab
|
|
@ -5,6 +5,8 @@ from sstv import SSTV, byte_to_freq
|
|||
|
||||
|
||||
class GrayscaleSSTV(SSTV):
|
||||
def on_init(self):
|
||||
self.pixels = self.image.convert('LA').load()
|
||||
|
||||
def gen_image_tuples(self):
|
||||
for line in xrange(self.HEIGHT):
|
||||
|
|
@ -15,11 +17,10 @@ class GrayscaleSSTV(SSTV):
|
|||
|
||||
def encode_line(self, line):
|
||||
msec_pixel = self.SCAN / self.WIDTH
|
||||
image = self.image.load()
|
||||
pixlen = len(image[0, line])
|
||||
image = self.pixels
|
||||
for col in xrange(self.WIDTH):
|
||||
pixel = image[col, line]
|
||||
freq_pixel = byte_to_freq(sum(pixel) / pixlen)
|
||||
freq_pixel = byte_to_freq(pixel[0])
|
||||
yield freq_pixel, msec_pixel
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue