kopia lustrzana https://github.com/dnet/pySSTV
moved freq-related functions to sstv module
rodzic
b43cf13511
commit
3644c050ae
5
color.py
5
color.py
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import division
|
||||
from sstv import FREQ_BLACK, FREQ_RANGE
|
||||
from sstv import byte_to_freq, FREQ_BLACK
|
||||
from grayscale import GrayscaleSSTV
|
||||
|
||||
class ColorSSTV(GrayscaleSSTV):
|
||||
|
@ -16,8 +16,7 @@ class ColorSSTV(GrayscaleSSTV):
|
|||
yield item
|
||||
for col in xrange(self.WIDTH):
|
||||
pixel = image.getpixel((col, line))
|
||||
value = pixel[index]
|
||||
freq_pixel = FREQ_BLACK + FREQ_RANGE * value / 255
|
||||
freq_pixel = byte_to_freq(pixel[index])
|
||||
yield freq_pixel, msec_pixel
|
||||
|
||||
def before_channel(self, index):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import division
|
||||
from sstv import FREQ_BLACK, FREQ_RANGE, FREQ_SYNC, SSTV
|
||||
from sstv import SSTV, byte_to_freq
|
||||
|
||||
class GrayscaleSSTV(SSTV):
|
||||
def gen_freq_bits(self):
|
||||
|
@ -13,16 +13,12 @@ class GrayscaleSSTV(SSTV):
|
|||
for item in self.encode_line(line):
|
||||
yield item
|
||||
|
||||
def horizontal_sync(self):
|
||||
yield FREQ_SYNC, self.SYNC
|
||||
|
||||
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
|
||||
freq_pixel = byte_to_freq(sum(pixel) / len(pixel))
|
||||
yield freq_pixel, msec_pixel
|
||||
|
||||
|
||||
|
|
7
sstv.py
7
sstv.py
|
@ -83,6 +83,13 @@ class SSTV(object):
|
|||
yield parity_freq, MSEC_VIS_BIT
|
||||
yield FREQ_SYNC, MSEC_VIS_BIT # stop bit
|
||||
|
||||
def horizontal_sync(self):
|
||||
yield FREQ_SYNC, self.SYNC
|
||||
|
||||
|
||||
def byte_to_freq(value):
|
||||
return FREQ_BLACK + FREQ_RANGE * value / 255
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from PIL import Image
|
||||
|
|
Ładowanie…
Reference in New Issue