Image Processing getting HSV components from colored image

I am trying to the the hue, saturation and value images from an image (originally colored). I converted the image using rgb2hsv() function but I am confused about how to get the 3 images from there.
Thanks in advance!

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 11 Okt. 2017
Bearbeitet: DGM am 29 Jan. 2025
hsv = rgb2hsv(YourRGBImage);
h_image = hsv(:,:,1);
s_image = hsv(:,:,2);
v_image = hsv(:,:,3);

1 Kommentar

DGM
DGM am 29 Jan. 2025
Bearbeitet: DGM am 29 Jan. 2025
(minor typo fix)
While I'm here:
Unlike other similar conversion tools, rgb2hsv() directly supports the output of a split image without manually splitting the channels as above or using imsplit().
% an RGB image
inpict = imread('peppers.png');
% method 1: manually split the image (any version)
hsvpict = rgb2hsv(inpict);
H = hsvpict(:,:,1);
S = hsvpict(:,:,2);
V = hsvpict(:,:,3);
% method 2: split the image using imsplit() (wouldn't have worked until R2018b)
hsvpict = rgb2hsv(inpict);
[H S V] = imsplit(hsvpict);
% method 3: get the channels directly from rgb2hsv() (any version)
[H S V] = rgb2hsv(inpict);
Again, that's really only a feature of rgb2hsv(). If you're using something else (e.g. rgb2lab(), rgb2ycbcr(), rgb2ntsc()), then you'll have to do method 1 or 2.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by