How to Converting RGB Image to HSI Image in MATLAB?
Converting the color space of an image is one of the most commonly performed operations in Image Processing. It is used so much as a lot of transformation/filters are performed on a specific color mode of an image. i.e. Thresholding is performed in Grayscale, Color slicing in HSV etc. A color space that has received a lot of attention overtime is HSL (Hue Saturation Intensity). This is because of the information that is obtained about the image and its contents just by the analysis of the channels. Therefore, it might be required to convert the image to HSI color space to perform some operation. Unfortunately, MATLAB does not have any built-in function for performing conversions to HSI color mode. So in this article, you will learn how to convert an RGB image to HSI image in MATLAB.
We would be using the following image for demonstration:
Firstly an RGB image named test.jpg is imported. Then all the values of each channel are divided by 255, giving us binary values which are stored in the variable I. Each channel of the RGB image is then obtained and stored in different variables. Then the image is converted to HSV color space using rgb2hsv function. This will allow the use of Hue and Saturation channels that are obtained from this conversation (would ease the process of getting the Hue and Saturation Channels). Then Hue and Saturation channels are stored in separate variables as well. Then the intensity of the image is obtained using the formula:
Then a zero matrix is created of the same size as the original image, and then populated with the Hue, Saturation and Intensity Channels. In the end, the HSI image is displayed.
Please Login to comment...