To achieve rgb to hsv conversion in matlab we can see that MATLAB Image processing toolbox provides functions for converting between different color spaces. Like to convert from RGB color space into HSV color space we have function called rgb2hsv() we need to pass RGB Image to this function and this function will return a HSV Image. Value of HSV will be between 0 and 1.
If we want to change or adjust Hue of the Image to correctly perceive some color adjustment with some factor, then after rgb to hsv conversion in matlab we can simply multiply Hue matrix with some factor and then reform the Image and finally make sure the resultant is not exceeding value from 0 and 1. We can then reconvert the Image back to RGB Color space by simply calling the function hsv2rgb() and passing the new HSV image to this function and will get back the hue adjusted RGB Image Like follows.
Understanding HSV Color Space
According to Wikipedia we can see the definition of HSV color space as this color space was designed to explain how human perceive colors. Here is quote form the Wikipedia
HSV (hue, saturation, value) are alternative representations of the RGB color model, designed in the 1970s by computer graphics researchers to more closely align with the way human vision perceives color-making attributes. In these models, colors of each hue are arranged in a radial slice, around a central axis of neutral colors which ranges from black at the bottom to white at the top.According to Wikipedia
basically the HSV color wheel goes from RED color to back to RED color. By traversing orange, yellow, green, cyan, blue, magenta colors.
First of all we need to read image and we are using the peppers.png image which comes along with Image processing toolbox from MATLAB. Then we convert the image int hsv color domain. After that, we parse all 3 matrix seperately and then change the hue with factor 1.5 (you can change this). Then we make sure to lie between 0 and 1 boundery by calling mod function.