-
-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement support for Y'CbCr matrices generation. #486
Comments
Adding some related code for future reference, it misses the offset though: def compute_YCbCr_matrix(weights, is_legal=False, bit_depth=8):
Kr, Kb = weights
Y_min, Y_max, C_min, C_max = colour.models.rgb.ycbcr.YCbCr_ranges(bit_depth, is_legal, False)
Y = np.array([Kr, (1 - Kr - Kb), Kb])
Cb = 0.5 * (np.array([0, 0, 1]) - Y) / (1 - Kb)
Cr = 0.5 * (np.array([1, 0, 0]) - Y) / (1 - Kr)
Y *= Y_max - Y_min
Cb *= C_max - C_min
Cr *= C_max - C_min
return np.linalg.inv(np.vstack([Y, Cb, Cr])) |
Should that code not also include the Would it be useful also to create a corresponding def compute_YCbCr_offsets(weights, is_legal=False, bit_depth=8, is_int=False):
Y_min, Y_max, C_min, C_max = colour.models.rgb.ycbcr.YCbCr_ranges(bit_depth, is_legal, is_int)
Y_offset = Y_min
C_offset = (C_min + C_max) / 2
return np.array([Y_min, C_offset, C_offset]) Then you could calculate the matrix and offsets and do: YCbCr = colour.utilities.dot_vector(matrix, RGB) + offsets |
Absolutely! It is not complete at all, I just pasted it so that I don't have to scroll for 10 hours in Slack :) |
Maybe propose an option to have the offset right into a 3x4 or 4x4 matrix as well ? |
This raises the question as to where the offsets would go in the 4x4 matrix. |
@nick-shaw and I talked about implementing a new
colour.RGB_to_YCbCr_matrix
definition that would generate the matrices used by the various Y'CbCr flavours, it would eventually be used by the currentcolour.RGB_to_YCbCr
andcolour.YCbCr_to_RGB
definitions.It would be beneficial for generating the matrices for usage in other applications and also probably faster.
The text was updated successfully, but these errors were encountered: