 YUVtoRGB - Maple Help

ImageTools

 YUVtoRGB
 convert a YUV color image to  an RGB color image Calling Sequence YUVtoRGB( img, opts ) Parameters

 img - ColorImage or ColorAImage; input image opts - (optional) equation(s) of the form option = value; specify options for the YUVtoRGB command Options

 • inplace = truefalse
 Specifies whether the operation is performed in-place. This can be used to avoid allocating memory. The default is false.
 • output = Image
 Specifies a data structure into which the output is written. This can be used to avoid allocating memory. The size and number of layers must match that of the input. The dimensions of the output image are adjusted so that the row and column indices match the input. The default is NULL. Description

 • The YUVtoRGB command converts a color image with a YUV color representation to an RGB color representation. The following linear transformation is applied at each position in the image to the three color layers:

$\mathrm{Matrix}\left(\left[\left[r\right],\left[g\right],\left[b\right]\right]\right)=\mathrm{Matrix}\left(\left[\left[1.,-0.00003945707070713,1.13982796717171708\right],\left[1.,-0.39461016414141419,-0.58050031565656568\right],\left[1.,2.03199968434343425,-0.00048137626262628\right]\right]\right)\mathrm{Matrix}\left(\left[\left[y\right],\left[u\right],\left[v\right]\right]\right)$

 • The alpha channel (layer 4), if present, is not affected.
 • The img parameter is the input image and must be of type ColorImage or ColorAImage. Examples

 > $\mathrm{with}\left(\mathrm{ImageTools}\right):$

Create three monochromatic layers representing the YUV layers and then combine them into a single image.

 > $\mathrm{img_y}≔\mathrm{Create}\left(100,200,\left(r,c\right)↦\mathrm{sin}\left(0.0025\cdot \left({c}^{2}+{r}^{2}\right)\right)\right):$
 > $\mathrm{img_y}≔0.2\left(1+2\mathrm{FitIntensity}\left(\mathrm{img_y}\right)\right):$
 > $\mathrm{img_u}≔\mathrm{Create}\left(100,200,\left(r,c\right)↦c\right):$
 > $\mathrm{img_u}≔0.436\left(-1+2\mathrm{FitIntensity}\left(\mathrm{img_u}\right)\right):$
 > $\mathrm{img_v}≔\mathrm{Create}\left(100,200,\left(r,c\right)↦r\right):$
 > $\mathrm{img_v}≔0.615\left(-1+2\mathrm{FitIntensity}\left(\mathrm{img_v}\right)\right):$
 > $\mathrm{img_yuv}≔\mathrm{CombineLayers}\left(\mathrm{img_y},\mathrm{img_u},\mathrm{img_v}\right):$

Convert the color image to an RGB representation and then extract each layer as a separate monochromatic image.

 > $\mathrm{img_rgb}≔\mathrm{YUVtoRGB}\left(\mathrm{img_yuv}\right):$
 > $\mathrm{img_r},\mathrm{img_g},\mathrm{img_b}≔\mathrm{op}\left(\mathrm{map2}\left(\mathrm{GetLayer},\mathrm{img_rgb},\left[1,2,3\right]\right)\right):$

Display the original YUV layers (after rescaling to an intensity between 0 and 1), the RGB image, and the RGB layers.

 > $\mathrm{Embed}\left(\mathrm{map}\left(\mathrm{FitIntensity},\left[\mathrm{img_y},\mathrm{img_u},\mathrm{img_v}\right]\right)\right)$   > $\mathrm{Embed}\left(\mathrm{img_rgb}\right)$ > $\mathrm{Embed}\left(\left[\mathrm{img_r},\mathrm{img_g},\mathrm{img_b}\right]\right)$   