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

122 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Image Analyst
Image Analyst il 9 Lug 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.
  2 Commenti
Alexandar
Alexandar il 9 Lug 2022
@Image Analyst Thank you so much for your help! Do you know any good introductory courses you can suggest for MATLAB imaging?

Accedi per commentare.

Più risposte (2)

DGM
DGM il 9 Lug 2022
Modificato: DGM il 9 Lug 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 il 9 Lug 2022
Modificato: Image Analyst il 9 Lug 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

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by