diff --git a/.gitignore b/.gitignore index 72bd210..520d278 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ demod.dat *.png +top_block.py diff --git a/render.py b/render.py index 7497f20..eee814f 100644 --- a/render.py +++ b/render.py @@ -35,10 +35,14 @@ def to_color(sample): return sample def ycbcr_to_rgb(y, cb, cr): - r = int(y + 1.402 * (cr - 128)) - g = int(y - 3.44136 * (cb - 128) - 0.714136 * (cr - 128)) - b = int(y + 1.772 * (cb - 128)) - return (r,g,b) + #https://stackoverflow.com/questions/4041840/function-to-convert-ycbcr-to-rgb/15333019#15333019 + cr = cr - 128 ; + cb = cb - 128 ; + r = y + 45 * cr / 32 ; + g = y - (11 * cb + 23 * cr) / 32 ; + b = y + 113 * cb / 64 ; + + return (int(r), int(g), int(b)) last_sync = False def is_sync(backlog): @@ -71,8 +75,8 @@ def render_lines(line): cb = to_color(line[2 * IMG_WIDTH + i]) y1 = to_color(line[3 * IMG_WIDTH + i]) - pixels[0][i] = y0, cb, cr - pixels[1][i] = y1, cb, cr + pixels[0][i] = ycbcr_to_rgb(y0, cb, cr) + pixels[1][i] = ycbcr_to_rgb(y1, cb, cr) return pixels @@ -115,14 +119,12 @@ def main(): plt.plot(syncs) plt.show() - img = Image.new('YCbCr', (IMG_WIDTH, len(pixels))) + img = Image.new('RGB', (IMG_WIDTH, len(pixels))) img_pix = img.load() for x in range(0, IMG_WIDTH): for y in range(0, len(pixels)): img_pix[x,y] = pixels[y][x] - img = img.convert('RGB') - img.save('output.png') diff --git a/sstv_demod.grc b/sstv_demod.grc index 9119b0b..75e0ce0 100644 --- a/sstv_demod.grc +++ b/sstv_demod.grc @@ -140,7 +140,7 @@ _coordinate - (979, 187) + (63, 410) _rotation @@ -199,7 +199,7 @@ _coordinate - (1011, 505) + (836, 513) _rotation @@ -474,7 +474,7 @@ _coordinate - (549, 442) + (302, 386) _rotation @@ -549,7 +549,7 @@ _coordinate - (1011, 402) + (828, 418) gui_hint @@ -916,7 +916,7 @@ _coordinate - (597, 115) + (661, 115) gui_hint @@ -952,7 +952,7 @@ color1 - 0 + 3 label1 @@ -1139,7 +1139,7 @@ _coordinate - (1011, 609) + (836, 609) gui_hint @@ -1175,7 +1175,7 @@ color1 - 0 + 3 label1 @@ -1354,7 +1354,7 @@ _coordinate - (732, 466) + (549, 410) _rotation