Last active
July 27, 2016 07:48
-
-
Save celoyd/210b7b3501389fcb6836e4d81c8838ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
# simple visualization of the Cb/Cr plane of an image | |
from skimage import io | |
import numpy as np | |
from sys import argv | |
src = io.imread(argv[1]) | |
print src.shape | |
R, G, B = src[:,:,0], src[:,:,1], src[:,:,2] | |
Y = (0.299 * R) + (0.587 * G) + (0.114 * B) | |
Cb = (-0.169 * R) - (0.331 * G) + (0.499 * B) + 128 | |
Cr = (0.499 * R) - (0.418 * G) - (0.0813 * B) + 128 | |
# traditional vectorscope orientation: | |
Cr = 256 - Cr | |
dst = np.zeros((256, 256), dtype=np.uint16) | |
for x in range(src.shape[0]): | |
for y in range(src.shape[1]): | |
dst[int(Cr[x, y]), int(Cb[x, y])] += 1 | |
io.imsave(argv[2], dst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment