How to Convert YIQ Image to RGB Image Using MATLAB?


In this article, we will learn how to convert a YIQ image into an RGB image using MATLAB programming.

YIQ is color space used in analog display devices to display color images. It uses three components namely, Y (brightness), I (In−Phase), and Q (Quadrature) to distinguish the image. Here, the Y component of the color space represents the luminance or brightness of the image, and the other two components, i.e. I and Q represent the color information of the image.

The YIQ is a NTSC (National Television System Committee) standard based color−space. It is used in analog video systems to separate color information from black and white information.

On the other hand, RGB is a color space that utilizes three−color channels, namely red, green, and blue to represent color images. In this color space, each pixel is represented as a combination of intensities of three−colors i.e., red, green, and blue. Hence, in an RGB image different colors are displayed by varying the intensity of these three colors.

Convert YIQ Image into RGB Image in MATLAB

MATLAB provides a built−in function ‘ntsc2rgb’ to convert a given YIQ image into an RGB image. The following syntax of this function is used to perform this transformation:

rgb_image = ntsc2rgb(yiq_image);

Algorithm

The step−by−step procedure to convert a YIQ image into an RGB image is explain below:

Step (1) − Read the YIQ image.

Step (2) − Convert the input YIQ image to double precision for accurate calculations.

Step (3) − Convert the input YIQ image into an RGB image using the ‘ntsc2rgb’ function.

Step (4) − Display the output RGB image.

Hence, it is clear that the conversion of a YIQ image into an RGB image in MATLAB is quite easy and straightforward process.

The following MATLAB program demonstrates the code implementation in MATLAB programming to convert a YIQ image into an RGB image.

Example

% MATLAB code for converting YIQ image into RGB image
% Read the YIQ image
yiq_img = imread('sample_yiq_img.png');

% Convert the input YIQ image to double precision for better calculations
yiq_img = im2double(yiq_img);

% Convert the input YIQ image to an RGB image
rgb_img = ntsc2rgb(yiq_img);

% Display the input YIQ and output RGB images
figure;
subplot(1, 2, 1); imshow(yiq_img); title('YIQ Image');
subplot(1, 2, 2); imshow(rgb_img); title('RGB Image');

Output

Code Explanation

This MATLAB program demonstrates the code implementation to convert a YIQ image into an RGB image. In this MATLAB code, we start by reading the input YIQ image using the ‘imread’ function and store it in a variable ‘yiq_img’. Then, we convert the input YIQ image to double precision using the ‘im2double’ function for more accurate calculations.

After that we convert the YIQ image into an RGB image using the ‘ntsc2rgb’ function. Finally, we display the input YIQ image and output RGB image side by side.

Conclusion

Hence, this is all about converting a YIQ image into an RGB image in MATLAB. In MATLAB, we have a built−in function ‘ntsc2rgb’ which allows us to convert a YIQ image into an RGB image.

Updated on: 07-Aug-2023

100 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements