def convolution_yuv(img, mask): from bt709 import to_yuv, to_rgb from skimage import img_as_float, img_as_ubyte import numpy as np cont_yuv = to_yuv(img_as_float(img)) cont_yuv[:, :, 0] = img_as_float(convolution(img_as_ubyte(cont_yuv[:, :, 0]), mask)) cont_rgb = img_as_ubyte(np.clip(to_rgb(cont_yuv), -1, 1)) return cont_rgb
def noising_yuv(img, ratio=1): from bt709 import to_yuv, to_rgb from skimage import img_as_float, img_as_ubyte import numpy as np cont_yuv = to_yuv(img_as_float(img)) cont_yuv[:, :, 0] = img_as_float(noising(img_as_ubyte(cont_yuv[:, :, 0]), ratio)) cont_rgb = img_as_ubyte(np.clip(to_rgb(cont_yuv), -1, 1)) return cont_rgb
def insert_dwm_wkey(rgb_container, dwm, key): from bt709 import to_yuv, to_rgb from skimage import img_as_float, img_as_ubyte import numpy as np cont_yuv = to_yuv(img_as_float(rgb_container)) cont_yuv[:, :, 0] = img_as_float( nzb_insert_secured(img_as_ubyte(cont_yuv[:, :, 0]), dwm, key)) cont_rgb = img_as_ubyte(np.clip(to_rgb(cont_yuv), -1, 1)) return cont_rgb
def rng_filter_yuv(method, img, mask=None): from bt709 import to_yuv, to_rgb from skimage import img_as_float, img_as_ubyte import numpy as np if mask is None: mask = np.array([[1] * 3] * 3) cont_yuv = to_yuv(img_as_float(img)) cont_yuv[:, :, 0] = img_as_float(rng_filter(method, img_as_ubyte(cont_yuv[:, :, 0]), mask)) cont_rgb = img_as_ubyte(np.clip(to_rgb(cont_yuv), -1, 1)) return cont_rgb