Convert RGB Image to YCbCr 4:2:2 Color Space
This example shows how to convert a pixel stream from R'G'B' color space to Y'CbCr 4:2:2 color space.
The model imports a 480p RGB image, then the Frame to Pixels block converts it to a pixel stream. Inside the HDL Algorithm subsystem, the Color Space Converter and Chroma Resampler blocks convert the pixel stream to YCbCr 4:2:2 format.
The waveform of the input and output pixel stream of the Chroma Resampler block shows the downsampling of the CbCr component values. The latency of the Chroma Resampler block depends on the size of the antialiasing filter. This example uses the default filter, which has 29 taps.
To check and generate the HDL code referenced in this example, you must have an HDL Coder™ license.
To generate the HDL code, use the following command.
makehdl('ChromaResampleExample/HDL Algorithm')
To generate the test bench, use the following command. Note that test bench generation takes a long time due to the large data size. Consider reducing the simulation time before generating the test bench.
makehdltb('ChromaResampleExample/HDL Algorithm')
The part of the model between the Frame to Pixels and Pixels to Frame blocks can be implemented on an FPGA.