YUV to RGB Image Conversion Tool

Resource Overview

Self-developed MATLAB implementation for converting YUV images to RGB format, supporting 4:4:4, 4:2:2, and 4:2:0 sampling formats with comprehensive color space transformation algorithms.

Detailed Documentation

This document presents my custom-developed code for converting YUV images to RGB format within the MATLAB environment. The implementation supports multiple chroma subsampling formats including 4:4:4, 4:2:2, and 4:2:0. The conversion process begins by loading the YUV image file and decoding it into separate luminance (Y) and chrominance (U, V) components. The code incorporates specialized sampling rate adjustment algorithms to handle different YUV formats - for 4:2:2 and 4:2:0 formats, the implementation includes intelligent upsampling routines to reconstruct full-resolution chroma components. Key functions include matrix-based color space transformation using the BT.601 or BT.709 standard conversion matrices, with optional gamma correction and color range scaling. The core algorithm applies the RGB conversion formula: R = Y + 1.402*(V-128), G = Y - 0.344*(U-128) - 0.714*(V-128), B = Y + 1.772*(U-128), with appropriate clamping to ensure valid RGB values (0-255 range). After processing the components (with options for brightness adjustment, contrast modification, or hue manipulation), the code reassembles the transformed components into a complete RGB image. The final output is saved in standard image file formats, providing a flexible solution for converting various YUV formats to RGB files with maintainable code structure and configurable parameters.