Name

rgb2hsv — Converts from RGB to HSV colorspace.

Calling Sequence

HSV = rgb2hsv(RGB)
HSVMAP = rgb2hsv(RGBMAP)

Parameters

RGB
A RGB image (M x N x 3) in 0-1 range or a RGB colormap (M x 3) in 0-1 range
HSV
A HSV image (M x N x 3) in 0-1 range or a HSV colormap (M x 3) in 0-1 range

Description

rgb2hsv(RGB) converts an RGB image or colormap to the HSV colorspace. The HSV model separates Hue (color) Saturation (ammount of color) and Value (intensity). It is much more useful for manipulation than the RGB space and also for segmenting images by color.

Examples


      rgb = imread(SIPDIR + 'images/tru.jpg'):
      xbasc();
      imshow(rgb);

      hsv = rgb2hsv(rgb);
      xbasc();
      imshow(hsv(:,:,3))  // intensity
      imshow(hsv(:,:,1))  // hue (color component)

      hsv(:,:,2) = 1      // saturate the image

      rgb = hsv2rgb(hsv);
      xbasc();
      imshow(rgb);

      // You may also convert a single triplet:

      rgb2hsv([1 1 0])

Authors

Ricardo Fabbri <ricardofabbri[at]users.sf.net>

Availability

The latest version of SIP can be found at

http://siptoolbox.sf.net

See Also

im2gray , hsv2rgb , rgb2ntsc , ntsc2rgb