![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Convert RGB Image to HSI Image in MATLAB?
In this article, we will discuss how to convert an RGB image into an HSI (HSV) image using MATLAB.
The RGB color space is widely used for displaying digital images on display screens. This color space utilizes a combination of intensities of red, green, and blue lights. Therefore, in the RGB color space, each pixel in a digital image composed of three−color channels namely red, green, and blue.
On the other hand, HSI stands for Hue Saturation and Intensity. It is also called HSV, where HSV stands for Hue Saturation Value. An image represented based on the color model of HSI is called an HSI image. The HSI color space utilizes three−channels namely Hue, Saturation, and Intensity (Value) to display the colors of an image. In the HSI color space, the Hue channel represents the color information of the image, the saturation channel represents the color intensity in the image, and the value or intensity channel represents the brightness of the image.
Convert RGB Image to HSI Image in MATLAB
MATLAB provides a built−in function ‘rgb2hsv’ to transform an RGB image to an HSI image. To perform this conversion the following syntax is used.
hsi_image = rgb2hsv(rgb_image);
Algorithm
The step−by−step procedure to convert an RGB image into an HSI image is explained below:
Step(1)− Read the input RGB image.
Step (2)− Convert the input RGB image to double precision for accurate calculations.
Step (3)− Convert the RGB image into HSI image using the ‘rgb2hsv’ function.
Step (4)− Display the output HSI image.
Hence, the conversion of an RGB image to an HSI image is a straightforward process in MATLAB.
The following MATLAB program shows the code implementation to convert an RGB image to an HSI image.
Example
% MATLAB program to convert RGB image to HSI image % Read the RGB image rgb_img = imread('https://www.tutorialspoint.com/assets/questions/media/14304-1687425236.jpg'); % Convert the RGB image to double precision for accurate calculations rgb_img = im2double(rgb_img); % Convert RGB image to HSI image hsi_img = rgb2hsv(rgb_img); % Display the RGB and HSI images figure; subplot(1, 2, 1); imshow(rgb_img); title('RGB Image'); subplot(1, 2, 2); imshow(hsi_img); title('HSI Image');
Output
![](https://www.tutorialspoint.com/assets/questions/media/334420-1691469652.jpg)
Code Explanation
This MATLAB program demonstrates the code implementation to convert an RGB image into an HSI image. In this code, firstly we read the input RGB image using the ‘imread’ function and store in a variable ‘rgb_img’. Then, we convert the input RGB image to double precision using the ‘im2double’ which is required for RGB to HSI conversion.
Next, we convert the input RGB image into HSI image using the ‘rgb2hsv’ function. Finally, we use the ‘disp’ function to display the RGB and HSI images.
Conclusion
Hence, this is all about converting an RGB image into an HSI image in MATLAB. In MATLAB programming, we have a built−in function ‘rgb2hsv’ that allows us to transform an RGB image into an HSI image. This conversion process involves very simple MATLAB coding as demonstrated in the above MATLAB program.