added ColorSSTV class, fixed fencepost div

This commit is contained in:
András Veres-Szentkirályi 2013-05-23 14:46:18 +02:00
parent 8690249bcc
commit a9984c6e39

26
sstv.py
View file

@ -88,14 +88,34 @@ class GrayscaleSSTV(SSTV):
def gen_freq_bits(self):
for item in SSTV.gen_freq_bits(self):
yield item
msec_pixel = self.SCAN / self.WIDTH
image = self.image
for line in xrange(self.HEIGHT):
yield FREQ_SYNC, self.SYNC
for item in self.encode_line(line):
yield item
def encode_line(self, line):
msec_pixel = self.SCAN / self.WIDTH
image = self.image
for col in xrange(self.WIDTH):
pixel = image.getpixel((col, line))
value = sum(pixel) / len(pixel)
freq_pixel = FREQ_BLACK + FREQ_RANGE * value / 256
freq_pixel = FREQ_BLACK + FREQ_RANGE * value / 255
yield freq_pixel, msec_pixel
class ColorSSTV(GrayscaleSSTV):
RED, GREEN, BLUE = range(3)
def encode_line(self, line):
cs = self.COLOR_SEQ
msec_pixel = self.SCAN / self.WIDTH
image = self.image
for col in xrange(self.WIDTH):
pixel = image.getpixel((col, line))
print pixel
for index in cs:
value = pixel[index]
freq_pixel = FREQ_BLACK + FREQ_RANGE * value / 255
yield freq_pixel, msec_pixel