1
0
Fork 0

Formatting fixes

master
James Taylor 2019-10-31 11:12:24 +00:00
parent 2459569c4c
commit ebb710e416
2 changed files with 4 additions and 11 deletions

View File

@ -13,7 +13,7 @@ def calc_lum(freq):
"""Converts SSTV pixel frequency range into 0-255 luminance byte"""
lum = int(round((freq - 1500) / 3.1372549))
return 255 if lum > 255 else 0 if lum < 0 else lum
return min(max(lum, 0), 255)
def barycentric_peak_interp(bins, x):
@ -23,15 +23,8 @@ def barycentric_peak_interp(bins, x):
# x value of the peak using neighbours in the bins array
# Make sure data is in bounds
if x <= 0:
y1 = bins[x]
else:
y1 = bins[x-1]
if x + 1 >= len(bins):
y3 = bins[x]
else:
y3 = bins[x+1]
y1 = bins[x] if x <= 0 else bins[x-1]
y3 = bins[x] if x + 1 >= len(bins) else bins[x+1]
denom = y3 + bins[x] + y1
if denom == 0:

View File

@ -10,7 +10,7 @@ def calc_freq(lum):
"""Converts 0-255 luminance byte into SSTV pixel frequency range"""
freq = (lum * 3.1372549) + 1500
return 2300 if freq > 2300 else 1500 if freq < 1500 else freq
return min(max(freq, 1500), 2300)
class SSTVEncoder(object):