org.gicentre.utils.colour
Class ColourConverter

java.lang.Object
  extended by org.gicentre.utils.colour.ColourConverter

public class ColourConverter
extends java.lang.Object

Utilities for converting between various colour spaces. Note that the default scaling for RGB is 0-1 and hue is expressed as degrees (0-360). For other values, see documentation for each conversion routine.

Version:
3.3, 1st August, 2011.
Author:
Jo Wood,giCentre, City University London. Includes modified code from Duane Schwartzwald and Harry Parker.

Nested Class Summary
static class ColourConverter.WhitePoint
          Whitepoint colour calibration settings.
 
Method Summary
static double[] getLab(java.awt.Color colour, ColourConverter.WhitePoint wp)
          Finds the CIELab triplet representing the given colour.
static double[] getLuv(java.awt.Color colour, ColourConverter.WhitePoint wp)
          Finds the CIELuv triplet representing the given colour.
static double[] labToRGB(double L, double a, double b, ColourConverter.WhitePoint wp)
          Finds the colour corresponding to the given CIELab triplet.
static double[] luvToRGB(double L, double u, double v, ColourConverter.WhitePoint wp)
          Finds the colour corresponding to the given CIELuv triplet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLab

public static double[] getLab(java.awt.Color colour,
                              ColourConverter.WhitePoint wp)
Finds the CIELab triplet representing the given colour. CIELab L value scaled between 0-100, and a and b values scaled between -100 and 100. Based on the conversion code by Duane Schwartzwald, 12th March, 2006 and Harry Parker, Feb 27th, 2007. See rsbweb.nih.gov/ij/plugins/download/Color_Space_Converter.java.

Parameters:
colour - Colour to convert.
wp - Whitepoint colour calibration value.
Returns:
Triplet of CIELab values in the order L, a and b.

getLuv

public static double[] getLuv(java.awt.Color colour,
                              ColourConverter.WhitePoint wp)
Finds the CIELuv triplet representing the given colour. CIELuv L value scaled between 0-100, and u and v values scaled between -100 and 100.

Parameters:
colour - Colour to convert.
wp - Whitepoint colour calibration value.
Returns:
Triplet of CIELuv values in the order L, u and v.

labToRGB

public static double[] labToRGB(double L,
                                double a,
                                double b,
                                ColourConverter.WhitePoint wp)
Finds the colour corresponding to the given CIELab triplet. Out-of-gamut colours will be returned as null if useNearest is false, otherwise the approximate nearest visible colour will be returned. CIELab L values should be scaled between 0-100, and a and b values scaled between -100 and 100. Based on the conversion code by Duane Schwartzwald, 12th March, 2006 and Harry Parker, Feb 27th, 2007. See rsbweb.nih.gov/ij/plugins/download/Color_Space_Converter.java.

Parameters:
L - CIELab L value scaled between 0 and 100.
a - CIELab a value scaled between -100 and 100.
b - CIELab b value scaled between -100 and 100.
wp - Whitepoint colour calibration value.
Returns:
RGB triplet representing the given Lab values. These are normally scaled between 0-1 for visible colours, but may be out of this range for out-of-gamut colours.

luvToRGB

public static double[] luvToRGB(double L,
                                double u,
                                double v,
                                ColourConverter.WhitePoint wp)
Finds the colour corresponding to the given CIELuv triplet. Out-of-gamut colours will be returned as null if useNearest is false, otherwise the approximate nearest visible colour will be returned. CIELuv L values should be scaled between 0-100, and u and v values scaled between -100 and 100.

Parameters:
L - CIELab L value scaled between 0 and 100.
u - CIELab u value scaled between -100 and 100.
v - CIELab v value scaled between -100 and 100.
wp - Whitepoint colour calibration value.
Returns:
RGB triplet representing the given Luv values. These are normally scaled between 0-1 for visible colours, but may be out of this range for out-of-gamut colours.


giCentre Utilities V.3.3, API documentation generated 6th April, 2013