kopia lustrzana https://github.com/dnet/pySSTV
optimized pixel access with explicit load()
rodzic
75292e2bee
commit
1a469c43d5
|
@ -11,12 +11,12 @@ class ColorSSTV(GrayscaleSSTV):
|
||||||
def encode_line(self, line):
|
def encode_line(self, line):
|
||||||
cs = self.COLOR_SEQ
|
cs = self.COLOR_SEQ
|
||||||
msec_pixel = self.SCAN / self.WIDTH
|
msec_pixel = self.SCAN / self.WIDTH
|
||||||
image = self.image
|
image = self.image.load()
|
||||||
for index in cs:
|
for index in cs:
|
||||||
for item in self.before_channel(index):
|
for item in self.before_channel(index):
|
||||||
yield item
|
yield item
|
||||||
for col in xrange(self.WIDTH):
|
for col in xrange(self.WIDTH):
|
||||||
pixel = image.getpixel((col, line))
|
pixel = image[col, line]
|
||||||
freq_pixel = byte_to_freq(pixel[index])
|
freq_pixel = byte_to_freq(pixel[index])
|
||||||
yield freq_pixel, msec_pixel
|
yield freq_pixel, msec_pixel
|
||||||
for item in self.after_channel(index):
|
for item in self.after_channel(index):
|
||||||
|
|
|
@ -15,9 +15,9 @@ class GrayscaleSSTV(SSTV):
|
||||||
|
|
||||||
def encode_line(self, line):
|
def encode_line(self, line):
|
||||||
msec_pixel = self.SCAN / self.WIDTH
|
msec_pixel = self.SCAN / self.WIDTH
|
||||||
image = self.image
|
image = self.image.load()
|
||||||
for col in xrange(self.WIDTH):
|
for col in xrange(self.WIDTH):
|
||||||
pixel = image.getpixel((col, line))
|
pixel = image[col, line]
|
||||||
freq_pixel = byte_to_freq(sum(pixel) / len(pixel))
|
freq_pixel = byte_to_freq(sum(pixel) / len(pixel))
|
||||||
yield freq_pixel, msec_pixel
|
yield freq_pixel, msec_pixel
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue