1
0
Fork 0

Fixed color conversion

Esse commit está contido em:
Sebastian 2019-02-17 00:04:09 +01:00
commit 66f69ae861
3 arquivos alterados com 21 adições e 18 exclusões

1
.gitignore externo
Ver arquivo

@ -1,2 +1,3 @@
demod.dat
*.png
top_block.py

Ver arquivo

@ -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')

Ver arquivo

@ -140,7 +140,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(979, 187)</value>
<value>(63, 410)</value>
</param>
<param>
<key>_rotation</key>
@ -199,7 +199,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(1011, 505)</value>
<value>(836, 513)</value>
</param>
<param>
<key>_rotation</key>
@ -474,7 +474,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(549, 442)</value>
<value>(302, 386)</value>
</param>
<param>
<key>_rotation</key>
@ -549,7 +549,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(1011, 402)</value>
<value>(828, 418)</value>
</param>
<param>
<key>gui_hint</key>
@ -916,7 +916,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(597, 115)</value>
<value>(661, 115)</value>
</param>
<param>
<key>gui_hint</key>
@ -952,7 +952,7 @@
</param>
<param>
<key>color1</key>
<value>0</value>
<value>3</value>
</param>
<param>
<key>label1</key>
@ -1139,7 +1139,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(1011, 609)</value>
<value>(836, 609)</value>
</param>
<param>
<key>gui_hint</key>
@ -1175,7 +1175,7 @@
</param>
<param>
<key>color1</key>
<value>0</value>
<value>3</value>
</param>
<param>
<key>label1</key>
@ -1354,7 +1354,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(732, 466)</value>
<value>(549, 410)</value>
</param>
<param>
<key>_rotation</key>