octave: Color Conversion

 
 32.5 Color Conversion
 =====================
 
 Octave supports conversion from the RGB color system to NTSC and HSV and
 vice versa.
 
  -- : HSV_MAP = rgb2hsv (RGB_MAP)
  -- : HSV_IMG = rgb2hsv (RGB_IMG)
      Transform a colormap or image from RGB to HSV color space.
 
      A color in the RGB space consists of red, green, and blue
      intensities.
 
      A color in HSV space is represented by hue, saturation and value
      (brightness) levels in a cylindrical coordinate system.  Hue is the
      azimuth and describes the dominant color.  Saturation is the radial
      distance and gives the amount of hue mixed into the color.  Value
      is the height and is the amount of light in the color.
 
      Output class and size will be the same as input.
 
      See also: Seehsv2rgb XREFhsv2rgb, Seergb2ind XREFrgb2ind,
      Seergb2ntsc XREFrgb2ntsc.
 
  -- : RGB_MAP = hsv2rgb (HSV_MAP)
  -- : RGB_IMG = hsv2rgb (HSV_IMG)
      Transform a colormap or image from HSV to RGB color space.
 
      A color in HSV space is represented by hue, saturation and value
      (brightness) levels in a cylindrical coordinate system.  Hue is the
      azimuth and describes the dominant color.  Saturation is the radial
      distance and gives the amount of hue mixed into the color.  Value
      is the height and is the amount of light in the color.
 
      The input can be both a colormap or RGB image.  In the case of
      floating point input, values are expected to be on the [0 1] range.
      In the case of hue (azimuth), since the value corresponds to an
      angle, ‘mod (h, 1)’ is used.
 
           >> hsv2rgb ([0.5 1 1])
           ⇒ ans = 0 1 1
 
           >> hsv2rgb ([2.5 1 1])
           ⇒ ans = 0 1 1
 
           >> hsv2rgb ([3.5 1 1])
           ⇒ ans = 0 1 1
 
      Output class and size will be the same as input.
 
      See also: Seergb2hsv XREFrgb2hsv, Seeind2rgb XREFind2rgb,
      Seentsc2rgb XREFntsc2rgb.
 
  -- : YIQ_MAP = rgb2ntsc (RGB_MAP)
  -- : YIQ_IMG = rgb2ntsc (RGB_IMG)
      Transform a colormap or image from red-green-blue (RGB) color space
      to luminance-chrominance (NTSC) space.  The input may be of class
      uint8, uint16, single, or double.  The output is of class double.
 
      Implementation Note: The reference matrix for the transformation is
 
           /Y\     0.299  0.587  0.114  /R\
           |I|  =  0.596 -0.274 -0.322  |G|
           \Q/     0.211 -0.523  0.312  \B/
 
      as documented in <http://en.wikipedia.org/wiki/YIQ> and truncated
      to 3 significant figures.  Note: The FCC version of NTSC uses only
      2 significant digits and is slightly different.
 
      See also: Seentsc2rgb XREFntsc2rgb, Seergb2hsv XREFrgb2hsv,
      Seergb2ind XREFrgb2ind.
 
  -- : RGB_MAP = ntsc2rgb (YIQ_MAP)
  -- : RGB_IMG = ntsc2rgb (YIQ_IMG)
      Transform a colormap or image from luminance-chrominance (NTSC)
      space to red-green-blue (RGB) color space.
 
      Implementation Note: The conversion matrix is chosen to be the
      inverse of the matrix used for rgb2ntsc such that
 
           x == ntsc2rgb (rgb2ntsc (x))
 
      MATLAB uses a slightly different matrix where rounding means the
      equality above does not hold.
 
      See also: Seergb2ntsc XREFrgb2ntsc, Seehsv2rgb XREFhsv2rgb,
      Seeind2rgb XREFind2rgb.