Clear Filters
Clear Filters

How to manipulate/change hue, saturation, and value of an image all together?

78 views (last 30 days)
I want to know how to manipulate the hue, saturation, and value of an image. I know that you can manipulate and RGB image to change the colors from red to yellow by using different numbers and I wanted to know if the same conceptr applies to HSV. I would greatly appreciate examples of this!
Particlulary I want to change the hue, saturation, and value by the value of .25 just to see how an image can change and then convert this back to an RGB image which I know is done through hsv2rgb, but I just don't know how to change the hsv part.

Accepted Answer

Image Analyst
Image Analyst on 9 Jul 2022
Try something like this:
% Convert to HSV
hsvImage = rgb2hsv(rgbImage);
% Get individual channels
[h, s, v] = imsplit(hsvImage);
% Add 0.25 to s image
s = s + 0.25;
% Add 0.25 to h image
h = h + 0.25;
% Make back into 3-D image
hsvImage = cat(3, h, s, v);
% Convert back into RGB
rgbImage = hsv2rgb(hsvImage);
You might have to convert rgbimage back into uint8 if the values are floating point values in the range 0-255.

More Answers (2)

DGM on 9 Jul 2022
Edited: DGM on 9 Jul 2022
If you like reinventing the wheel every single time and only want to use HSV, feel free. There are advantages in terms of flexibility, but you'll have to at least make sure to preserve the continuity of H. If you want to use another color model, things get more complicated.
Barring direct conversion and manipulation methods, there aren't really concise color adjustment tools in base MATLAB/IPT. There are purpose-built third-party tools.
MIMT imtweak can do most simple tasks in one line, and the image class is preserved. Imtweak() supports operations in several color models other than HSV, which may be beneficial if you are concerned about preserving brightness/contrast while adjusting hue and saturation. In that regard, HSV is probably the worst thing to use.
This is one example. I've used it in many other examples here as well, so a forum search should turn up others that may be tangentially related.

Image Analyst
Image Analyst on 9 Jul 2022
Edited: Image Analyst on 9 Jul 2022
Alexander, to learn more about image processing with MATLAB:
Try my File Exchange:
Also see the examples in the web site for the IMage Processing Toolbox.
Also see Steve's blog:
and File Exchange:
Steve is the leader of the Image Processing Team. He also has a textbook about it.
Also see


Find more on Image Processing Toolbox in Help Center and File Exchange




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!