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!

 Accepted Answer

hsv = rgb2hsv(YourRGBImage);
h_image = hsv(:,:,1);
s_image = hsv(:,:,2);
v_image = hsv(:,:,3);

1 Comment

(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.

Sign in to comment.

More Answers (0)

Asked:

on 11 Oct 2017

Edited:

DGM
on 29 Jan 2025

Community Treasure Hunt

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

Start Hunting!