org.jscience.util
Class ColorUtils

java.lang.Object
  extended by org.jscience.util.ColorUtils

public class ColorUtils
extends java.lang.Object

An set of utility functions that convert from one color space to another.

The RGB<->HSV color space conversions have been taken from Foley & van Dam Computer Graphics Principles and Practice, 2nd Edition, Addison Wesley, 1990.

The RGB <-> YUV colorspace conversion is based on the formulas found at http://astronomy.swin.edu.au/~pbourke/colour/convert/


Constructor Summary
ColorUtils()
           
 
Method Summary
static void convertHSVtoRGB(float[] hsv, float[] rgb)
          Change an HSV color to RGB color.
static void convertHSVtoRGB(float h, float s, float v, float[] rgb)
          Change an HSV color to RGB color.
static void convertRGBtoHSV(float[] rgb, float[] hsv)
          Change an RGB color to HSV color.
static void convertRGBtoHSV(float r, float g, float b, float[] hsv)
          Change an RGB color to HSV color.
static void convertRGBtoYIQ(float[] rgb, float[] yiq)
          Change an RGB color to YIQ (JPEG) color.
static void convertRGBtoYUV(float[] rgb, float[] yuv)
          Change an RGB color to YUV (YCrCb) color.
static void convertYIQtoRGB(float[] yiq, float[] rgb)
          Change an YIQ (JPEG) color to RGB color.
static void convertYUVtoRGB(float[] yuv, float[] rgb)
          Change an YUV (YCrCb) color to RGB color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorUtils

public ColorUtils()
Method Detail

convertRGBtoHSV

public static void convertRGBtoHSV(float[] rgb,
                                   float[] hsv)
Change an RGB color to HSV color. We don't bother converting the alpha as that stays the same regardless of color space.

Parameters:
rgb - The array of RGB components to convert
hsv - An array to return the colour values with

convertRGBtoHSV

public static void convertRGBtoHSV(float r,
                                   float g,
                                   float b,
                                   float[] hsv)
Change an RGB color to HSV color. We don't bother converting the alpha as that stays the same regardless of color space.

Parameters:
r - The r component of the color
g - The g component of the color
b - The b component of the color
hsv - An array to return the HSV colour values in

convertHSVtoRGB

public static void convertHSVtoRGB(float[] hsv,
                                   float[] rgb)
Change an HSV color to RGB color. We don't bother converting the alpha as that stays the same regardless of color space.

Parameters:
hsv - The HSV component of the color as an array
rgb - An array to return the RGB colour values in

convertHSVtoRGB

public static void convertHSVtoRGB(float h,
                                   float s,
                                   float v,
                                   float[] rgb)
Change an HSV color to RGB color. We don't bother converting the alpha as that stays the same regardless of color space.

Parameters:
h - The h component of the color
s - The s component of the color
v - The v component of the color
rgb - An array to return the RGB colour values in

convertRGBtoYUV

public static void convertRGBtoYUV(float[] rgb,
                                   float[] yuv)
Change an RGB color to YUV (YCrCb) color. The colour value conversion is independent of the colour range. Colours could be 0-1 or 0-255.

Parameters:
rgb - The array of RGB components to convert
yuv - An array to return the colour values with

convertYUVtoRGB

public static void convertYUVtoRGB(float[] yuv,
                                   float[] rgb)
Change an YUV (YCrCb) color to RGB color. The colour value conversion is independent of the colour range. Colours could be 0-1 or 0-255.

Parameters:
yuv - The array of YUV components to convert
rgb - An array to return the colour values with

convertRGBtoYIQ

public static void convertRGBtoYIQ(float[] rgb,
                                   float[] yiq)
Change an RGB color to YIQ (JPEG) color. The colour value conversion is independent of the colour range. Colours could be 0-1 or 0-255.

Parameters:
rgb - The array of RGB components to convert
yiq - An array to return the colour values with

convertYIQtoRGB

public static void convertYIQtoRGB(float[] yiq,
                                   float[] rgb)
Change an YIQ (JPEG) color to RGB color. The colour value conversion is independent of the colour range. Colours could be 0-1 or 0-255.

Parameters:
yiq - The array of YIQ components to convert
rgb - An array to return the colour values with