.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/image/image_yuv.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__gallery_image_image_yuv.py: YUV Image ========= Example that shows how to use YUV images. Most videos are stored in this colorspace. Y stores luma at full resolution, UV stores chroma values. In yuv420p UV channels are stored at half the resolution of Y. In yuv444p, UV channels are stored at full resolution. YUV is also called YCbCr for digital images. For more info: https://en.wikipedia.org/wiki/Y%E2%80%B2UV You can see the slight differences between yuv420 and yuv444 if you zoom into parts of the image where colors change rapidly over space, such as the astronaut's patch. .. GENERATED FROM PYTHON SOURCE LINES 17-56 .. image-sg:: /_gallery/image/images/sphx_glr_image_yuv_001.webp :alt: image yuv :srcset: /_gallery/image/images/sphx_glr_image_yuv_001.webp :class: sphx-glr-single-img .. code-block:: Python # test_example = true import fastplotlib as fpl import numpy as np from skimage.color import rgb2ycbcr import imageio.v3 as iio # convert an rgb image to ycbcr for example purposes img = iio.imread("imageio:astronaut.png") img_yuv = rgb2ycbcr(img).astype(np.uint8) y = img_yuv[..., 0] u = img_yuv[..., 1] v = img_yuv[..., 2] figure = fpl.Figure( shape=(1, 2), names=["yuv420p", "yuv444p"], controller_ids="sync", size=(700, 400) ) image1 = figure[0, 0].add_image_yuv( data=(y, u[::2, ::2], v[::2, ::2]), colorspace="yuv420p" ) image2 = figure[0, 1].add_image_yuv(data=(y, u, v), colorspace="yuv444p") cursor = fpl.Cursor() for subplot in figure: cursor.add_subplot(subplot) figure.show() # NOTE: fpl.loop.run() should not be used for interactive sessions # See the "JupyterLab and IPython" section in the user guide if __name__ == "__main__": print(__doc__) fpl.loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.928 seconds) .. _sphx_glr_download__gallery_image_image_yuv.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: image_yuv.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: image_yuv.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_