Skip to content
Snippets Groups Projects
Commit 00bc1b4f authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

ycbcr2rgb

parent 6eb19208
No related branches found
No related tags found
1 merge request!200python ftl-file v3
Pipeline #17179 passed
......@@ -25,7 +25,7 @@ except ImportError:
''' YCrCb to RGB, based on OpenCV documentation definition.
Note: It seems this implementation is not perfectly equivalent to
OpenCV's
OpenCV's (results not exactly same, why?)
'''
rgb = np.zeros(img.shape, np.float)
......@@ -41,6 +41,20 @@ except ImportError:
return rgb.round().astype(np.uint8)
def _ycbcr2rgb(img):
rgb = np.zeros(img.shape, np.float)
Y = img[:,:,0].astype(np.float)
Cr = img[:,:,2].astype(np.float)
Cb = img[:,:,1].astype(np.float)
delta = 128.0
rgb[:,:,0] = Y + 1.403 * (Cr - delta)
rgb[:,:,1] = Y - 0.714 * (Cr - delta) - 0.344 * (Cb - delta)
rgb[:,:,2] = Y + 1.773 * (Cb - delta)
return rgb.round().astype(np.uint8)
class FTLStreamWriter:
def __init__(self, file, version=2):
self._file = open(file, "wb")
......@@ -237,7 +251,7 @@ class FTLStreamReader:
if self._version < 3:
self._frame = _ycrcb2rgb(img)
else:
self._frame = img
self._frame = _ycbcr2rgb(img)
def _decode_opencv(self, sp, p):
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment