Open In App

How to Convert YIQ Image to RGB Image Using MATLAB?

Converting images from one color space to another is a handy process in image processing that provides convenience and eases the overall process by choosing the most accurate color space to work the image on. The YIQ color space, as the name suggests comprises of three components namely Luma (Y), In-Phase(I), and Quadrature(Q).  

A brief description of each component is as follows.



Approach:

We will be using the inbuilt MATLAB images for illustration purposes. If the user wishes to use any other image then one essential thing that needs to be checked is that the directory of the image and the MATLAB code are the same otherwise an error prompt would be shown. One example of this kind is also illustrated by taking the geeks for geeks logo.

The image used in the following example is a lighthouse. These images are already in RGB color space so for testing purposes we will convert to YIQ and using that as new input we will convert them back to YIQ. Default images in YIQ format are scarce in number as the color space is not commonly used.



Example 1 :




% MATLAB code for convert images in YIQ format
% Reading the Original image and
% converting to YIQ format.
% This YIQ format image will be
% effectively used as input.
% Make sure the image file path is in
% the same directory as code.
I = imread('GFG.jpeg');
J = rgb2ntsc(I);
 
% Creating figure window for the input image
% Displaying the input image
figure;
imshow(J);
 
% Converting YIQ to RGB
K = ntsc2rgb(J);
 
% Displaying the RGB Image
figure;
imshow(K);

 
 

Output:

 

Figure 1: Input Image in YIQ Color Space

 

Figure 2: Output Image in RGB Color Space

Example 2:

 




% MATLAB code
% Reading the Original image and converting
% to YIQ format. This YIQ format image will
% be effectively used as input.
I = imread('lighthouse.png');
J = rgb2ntsc(I);
 
% Creating figure window for the input image
% Displaying the input image
figure;
imshow(J);
 
% Converting YIQ to RGB
K = ntsc2rgb(J);
 
% Displaying the RGB Image
figure;
imshow(K);

 

 

Figure 3: Input Image in YIQ color space 

Figure 4 : Output image in RGB color space

Code Explanation:

Thus we have achieved the task of converting an image from YIQ color space to RGB color space.

 


Article Tags :