UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Moderator
Moderator
1,323 Views
Registered: ‎11-09-2015

Video Beginner Series 9: YUV/YCbCr Color Space on AXI4-Stream Interface

Introduction

 

This Video Beginner Series 9 is an introduction to YUV/YCbCr color spaces and how to convert video data from/to YUV/YCbCr on Xilinx devices.

 

 

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Summary

 

1. YUV and YCbCr color space

2. Converting YUV/YCbCr from/to RGB on Xilinx devices

3. Tutorial - Converting video data from YUV to RGB color space

4. What next?

 

 


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
4 Replies
Moderator
Moderator
1,320 Views
Registered: ‎11-09-2015

Video Beginner Series 9: YUV/YCbCr Color Space on AXI4-Stream Interface - YUV and YCbCr color space

YUV and YCbCr color space

 

 

What is a color space

 

A color space is a way to represent colors. In a computer you will often talk about RGB (for Red Green Blue). This is easy to visualize for human brain as it is like when you play with paint. If you mix some Red pain with some blue pain, you will get a Violet color (it is called additive colors).

This is the same for a pixel in the RGB color space. If its blue and red components have a high value while its green component is low, the pixel will be violet.

 

 

YUV color space

 

First televisions were in Black and White (B&W). When the first color television arrived it needed to be compatible with B&W TV infrastructure while being able to get color information. The B&W system used only the luminance information (represented Y). The color information (called chrominance and represented by U and V) was added on top of it.

 

 

YCbCr

 

YCbCr is a scaled and offset version of the YUV color space. Y also represent the luminance and Cb and Cr represent the choma components containing the color information.

There are different standard defining YCbCr as per example ITU-R BT601, ITU-R BT709 or ITU-R BT.2020

 

1.png

 


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
Moderator
Moderator
1,318 Views
Registered: ‎11-09-2015

Video Beginner Series 9: YUV/YCbCr Color Space on AXI4-Stream Interface - Converting YUV/YCbCr from/to RGB on Xilinx devices

Converting YUV/YCbCr from/to RGB on Xilinx devices

 

 

Xilinx Video IPs to convert YUV/YCbCr from/to RGB

 

Xilinx IP catalog contains 3 IPs (dedicated) to convert YUV/YCbCr data from/to the RGB.

The recommendation is to use the Video Processing Subsystem (VPSS) IP. The documentation for the VPSS can be found in PG231. One thing to note is that the VPSS IP requires the use of a processor (Zynq or MicroBlaze) to be programmed through an AXI4-Lite.

For design without processor, a solution is to use the logiCORE RGB to YCrCb Color‐Space Converter IP (documented in PG013) or the logiCORE YCrCb to RGB Color‐Space Converter IP (documented in PG014).

 

 

YUV/YCbCr mapping on the AXI4-Stream Interface

 

On an AXI4-Stream Interface connecting a Xilinx Video IP (as defined by UG934), the Y component is mapped on the LSB, followed by the Cb component and then the Cr component

 

2.png

 

 

 


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
Moderator
Moderator
1,308 Views
Registered: ‎11-09-2015

Video Beginner Series 9: YUV/YCbCr Color Space on AXI4-Stream Interface - Tutorial - Converting video data from YUV to RGB color space

Tutorial - Converting video data from YUV to RGB color space

 

Note 1: This tutorial is intended to be used only with Vivado 2018.1 and only in simulation

Note 2: A valid license for the Test Pattern Generator is required to build the design.

 

Build the Vivado project

 

  1. Download the tutorial files and unzip the folder

  2. Open Vivado 2018.1

  3. In the tcl console, cd into the unzipped directory (cd <path>/XVES_0009)

  4. In the tcl console, source the script tcl (source ./create_proj.tcl)

  5. Open the BD design. You can see that it only contains a test pattern generator controlled by a VIP IP.

3.png

 

 

Get the RGB output

 

  1. Run the simulation for 6ms.

  2. An output image proj_1/proj_1.sim/sim_1/behav/xsim/TPG_RGB.ppm was created. Open it with GIMP. We can see that this is the color bar pattern in TGB color space

4.png

 

 

Configure the TPG IP to output YUV data

 

  1. Configure the TPG IP to output YUV. Open the test bench file tb_YUV_RGB.sv and find lines 184-185:

//Set TPG output color space
master_agent.AXI4LITE_WRITE_BURST(TPG_COLOR_FORMAT_REG,0,TPG_RGB_OUT,resp);

Change line 185 to:

 

master_agent.AXI4LITE_WRITE_BURST(TPG_COLOR_FORMAT_REG,0,TPG_YUV_OUT,resp);

 

  1. Additionally, change the output file name to TPG_YUV.ppm on line 230

  2. Save the test bench file and re-run the simulation for 6ms

  3. If we open the new image file crated proj_1/proj_1.sim/sim_1/behav/xsim/TPG_YUV.ppm we can see that it looks like the same pattern but with different colors. This is because we are trying to display YUV colors while GIMP thinks it is RGB

5.png

 

  1. A better way to look at it would be to look at each individual layer. In GIMP, click Colors > Components > Decompose

  2. In the Decompose window, select RGB as Color Model, uncheck Decompose to layers and click ok

6.png

 

Note: The reason why we select RGB is because GIMP thinks our input is RGB. The Decompose will with RGB settings (if input is RGB) will only split the image into 3 different images (1 for each component).

 

  1. 3 new windows will open, one for each component.

 7.png

 

 

  1. The window called YUV-red.ppm correspond to the Y component, the YUV-green.ppm and YUV-blue.ppm to Cb and Cr components.

 

Converting the AXI4-Stream YUV data to RGB

 

  1. Open the block design.

  2. Delete the wire between the AXI4_Stream_out output and the TPG

  3. Right-click on the BD and click Add IP…. Search for ycrcb2rgb and press ENTER.

8.png

 

  1. Double click on the YCrCb to RGB IP to open its configuration GUI. Change the following parameters:
  • Pixels Per Scanline: 640
  • Scanlines per Frame: 400
  • Standard Selection: HD ITU 709 1250 PAL
  • Output Range Selection: 0 to 255 for Computer Graphics

9.png

 

  1. Connect the video_in input to the TPG m_axis_video output and the video_out to the BD AXI4_Stream_out output

  2. Connect aclk and aresetn to the ports aclk_50MHz and aresetn_0

10.png 

 

  1. Validate and save the BD.

  2. Open the test bench file and change the output file name to converted_RGB.ppm. Save the test bench file

  3. Launch the simulation and run it for 6ms.

  4. Open the generated image proj_1/proj_1.sim/sim_1/behav/xsim/converted_RGB.ppm. We can see that we have the pattern in RGB at the output

11.png

 

 


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
Highlighted
Moderator
Moderator
1,306 Views
Registered: ‎11-09-2015

Video Beginner Series 9: YUV/YCbCr Color Space on AXI4-Stream Interface - What Next?

What Next?

 

 

  • You liked this Video Series?
    • You can give Kudos using the Kudos button  kudos.PNG
    • Make sure you are following the Xilinx Video Series topic to be informed when an new topic is published (Go to the Xilinx Video Series topic > Options > Subscribe)
      subscribe.PNG

 


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos