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
| # The coefficients were taken from OpenCV https://github.com/opencv/opencv | |
| # I'm not sure if the values should be clipped, in my (limited) testing it looks alright | |
| # but don't hesitate to add rgb.clip(0, 1, rgb) & yuv.clip(0, 1, yuv) | |
| # | |
| # Input for these functions is a numpy array with shape (height, width, 3) | |
| # Change '+= 0.5' to '+= 127.5' & '-= 0.5' to '-= 127.5' for values in range [0, 255] | |
| def rgb2yuv(rgb): | |
| m = np.array([ | |
| [0.29900, -0.147108, 0.614777], |