mirror of
https://github.com/dnet/pySSTV.git
synced 2025-12-06 07:12:00 +01:00
added ColorSSTV class, fixed fencepost div
This commit is contained in:
parent
8690249bcc
commit
a9984c6e39
32
sstv.py
32
sstv.py
|
|
@ -88,14 +88,34 @@ class GrayscaleSSTV(SSTV):
|
||||||
def gen_freq_bits(self):
|
def gen_freq_bits(self):
|
||||||
for item in SSTV.gen_freq_bits(self):
|
for item in SSTV.gen_freq_bits(self):
|
||||||
yield item
|
yield item
|
||||||
msec_pixel = self.SCAN / self.WIDTH
|
|
||||||
image = self.image
|
|
||||||
for line in xrange(self.HEIGHT):
|
for line in xrange(self.HEIGHT):
|
||||||
yield FREQ_SYNC, self.SYNC
|
yield FREQ_SYNC, self.SYNC
|
||||||
for col in xrange(self.WIDTH):
|
for item in self.encode_line(line):
|
||||||
pixel = image.getpixel((col, line))
|
yield item
|
||||||
value = sum(pixel) / len(pixel)
|
|
||||||
freq_pixel = FREQ_BLACK + FREQ_RANGE * value / 256
|
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 / 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
|
yield freq_pixel, msec_pixel
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue