How to Convert HSI Image to RGB Image in MATLAB?


HSI (also called HSV) and RGB are two different types of color spaces. Where, HSI stands for Hue Saturation and Intensity, (HSV stands for Hue Saturation Value). An image represented based on the color model of HSI is called an HSI image. On the other hand, RGB stands for Red Green and Blue. It is another popular color space in which images are represented based on red, green, and blue color intensities.

In this article, we will study how to convert an HSI image into an RGB image using MATLAB programming.

MATLAB provides a built−in function ‘hsv2rgb’ to convert an HSI image to an RGB image.

We can perform this conversion as per the following steps:

Step (1) − Read the input HSI image.

Step (2) − Use the function ‘hsv2rgb’ to convert the input HSI image to the RGB image.

Step (3) − Display the output RGB image.

It can be seen that the process of converting an HSI image to an RGB image is quite simple and straightforward.

Now, let us consider a few example MATLAB programs to perform this conversion.

Example

% MATLAB code for converting an HSI image to an RGB image 
% Read the input HSI Image
hsi_img = imread('hsi_image_1.png');	% Replace the image address to your HSI image

% Convert the HSI image to double precision for better calculations
hsi_img = im2double(hsi_img);

% Convert the HSI image to RGB image
rgb_img = hsv2rgb(hsi_img);

% Display the HSI and RGB Images
subplot(1, 2, 1); imshow(hsi_img); title('HSI Image');
subplot(1, 2, 2); imshow(rgb_img); title('RGB Image');

Output

Code Explanation

In this MATLAB code, we start by reading the input HSI image using the ‘imread’ function and store it in a variable “hsi_img”.

Next, we convert the input HSI image to double precision by using the ‘im2double’ function for better calculations. Then, we use the ‘hsv2rgb’ function to convert the input HSI image to RGB image.

Finally, we display the HSI image and RGB image using the ‘imshow’ function with a proper title.

Example

% MATLAB code for converting an HSI image to an RGB image 
% Read the input HSI Image
hsi_img = imread('hsi_image_2.png');	% Replace the image address to your HSI image

% Convert the HSI image to double precision for better calculations
hsi_img = im2double(hsi_img);

% Convert the HSI image to RGB image
rgb_img = hsv2rgb(hsi_img);

% Display the HSI and RGB Images
subplot(1, 2, 1); imshow(hsi_img); title('HSI Image');
subplot(1, 2, 2); imshow(rgb_img); title('RGB Image');

Output

Code Explanation

The implementation and execution of this code is similar to that of the MATLAB program 1.

Conclusion

Hence, this is all about converting an HSI (HSV) image to an RGB image using MATLAB coding. As described above, MATLAB provides a built−in function ‘hsv2rgb’ to perform the conversion of an HSI image to an RGB image. The implementation for this conversion can be understood from the above two examples programs. In the above two programs, you have to replace the image address with the address of your HSI image in the ‘imread’ function to get the result.

Updated on: 07-Aug-2023

201 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements