Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e025fa0
commit 4a8c4a2
Showing
4 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
def rgb2ycbcr(r, g, b): | ||
y = int(0.299*r + 0.587*g + 0.114*b) | ||
cb = int(-0.1687*r - 0.3313*g + 0.5*b + 128) | ||
cr = int(0.5*r - 0.4187*g - 0.0813*b + 128) | ||
return y, cb, cr | ||
|
||
color_bars_rgb = [ | ||
[255, 255, 255], | ||
[255, 255, 0], | ||
[0, 255, 255], | ||
[0, 255, 0], | ||
[255, 0, 255], | ||
[255, 0, 0], | ||
[0, 0, 255], | ||
[0, 0, 0], | ||
] | ||
|
||
color_bars_ycbcr = [] | ||
for color_bar_rgb in color_bars_rgb: | ||
r, g, b = color_bar_rgb | ||
y, cb, cr = rgb2ycbcr(r, g, b) | ||
color_bars_ycbcr.append([y, cb, cr]) | ||
|
||
for color_bar_ycbcr in color_bars_ycbcr: | ||
y, cb, cr = color_bar_ycbcr | ||
value = y | ||
value |= cr << 8 | ||
value |= y << 16 | ||
value |= cb << 24 | ||
print("%08x" %value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters