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
26
sstv.py
26
sstv.py
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue