JIGL
v1.6

jigl.image.utils
Class ColorSpace

java.lang.Object
  |
  +--jigl.image.utils.ColorSpace

public class ColorSpace
extends Object

This class converts between colorspaces. Currently supports conversions:

      RGB<-->HSV, RGB<-->HLS, RGB<-->CMY, RGB<-->YIQ
 


Constructor Summary
ColorSpace()
          Constructor
 
Method Summary
static float[] CMYtoRGB(float[] cmy)
          Converts a RealColorImage value from CMY to RGB colorspace.
static RealColorImage CMYtoRGB(RealColorImage image)
          Converts an image from CMY to RGB colorspace.
static float[] HLStoRGB(float[] hls)
          Converts a RealColorImage value from HLS to RGB colorspace.
static RealColorImage HLStoRGB(RealColorImage image)
          Converts an image from HLS to RGB colorspace.
static float[] HSVtoRGB(float[] hsv)
          Converts a RealColorImage value from HSV to RGB colorspace.
static RealColorImage HSVtoRGB(RealColorImage image)
          Converts an image from HSV to RGB colorspace.
private static float maximum(float[] val)
          Find the maximum among val[0], val[1] and val[2].
private static float minimum(float[] val)
          Find the minimum among val[0], val[1] and val[2].
static float[] RGBtoCMY(float[] rgb)
          Converts a RealColorImage value from RGB to CMY colorspace.
static RealColorImage RGBtoCMY(RealColorImage image)
          Converts an image from RGB to CMY colorspace.
static float[] RGBtoHLS(float[] rgb)
          Converts a RealColorImage value from RGB to HLS colorspace.
static RealColorImage RGBtoHLS(RealColorImage image)
          Converts an image from RGB to HLS colorspace.
static float[] RGBtoHSV(float[] rgb)
          Converts a RealColorImage value from RGB to HSV colorspace.
static RealColorImage RGBtoHSV(RealColorImage image)
          Converts an image from RGB to HSV colorspace.
static float[] RGBtoYIQ(float[] rgb)
          Converts a RealColorImage value from RGB to YIQ colorspace.
static RealColorImage RGBtoYIQ(RealColorImage image)
          Converts an image from RGB to YIQ colorspace.
private static float value(float n1, float n2, float hue)
          Utility method.
static float[] YIQtoRGB(float[] yiq)
          Converts a RealColorImage value from YIQ to RGB colorspace.
static RealColorImage YIQtoRGB(RealColorImage image)
          Converts an image from YIQ to RGB colorspace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorSpace

public ColorSpace()
Constructor

Method Detail

maximum

private static float maximum(float[] val)
Find the maximum among val[0], val[1] and val[2].


minimum

private static float minimum(float[] val)
Find the minimum among val[0], val[1] and val[2].


value

private static float value(float n1,
                           float n2,
                           float hue)
Utility method.


RGBtoHSV

public static RealColorImage RGBtoHSV(RealColorImage image)
Converts an image from RGB to HSV colorspace.

Parameters:
image - RealColorImage to convert
Returns:
deep copy of image

HSVtoRGB

public static RealColorImage HSVtoRGB(RealColorImage image)
                               throws NotHSVColorSpaceException
Converts an image from HSV to RGB colorspace.

Parameters:
image - RealColorImage to convert
Returns:
deep copy of image
NotHSVColorSpaceException

RGBtoHLS

public static RealColorImage RGBtoHLS(RealColorImage image)
Converts an image from RGB to HLS colorspace.

Parameters:
image - RealColorImage to convert
Returns:
deep copy of image

HLStoRGB

public static RealColorImage HLStoRGB(RealColorImage image)
                               throws NotHLSColorSpaceException
Converts an image from HLS to RGB colorspace.

Parameters:
image - RealColorImage to convert
Returns:
deep copy of image
NotHLSColorSpaceException

RGBtoCMY

public static RealColorImage RGBtoCMY(RealColorImage image)
Converts an image from RGB to CMY colorspace.

Parameters:
image - RealColorImage to convert
Returns:
deep copy of image

CMYtoRGB

public static RealColorImage CMYtoRGB(RealColorImage image)
Converts an image from CMY to RGB colorspace.

Parameters:
image - RealColorImage to convert
Returns:
deep copy of image

RGBtoYIQ

public static RealColorImage RGBtoYIQ(RealColorImage image)
Converts an image from RGB to YIQ colorspace.

Parameters:
image - RealColorImage to convert
Returns:
deep copy of image

YIQtoRGB

public static RealColorImage YIQtoRGB(RealColorImage image)
Converts an image from YIQ to RGB colorspace.

Parameters:
image - RealColorImage to convert
Returns:
deep copy of image

RGBtoHSV

public static float[] RGBtoHSV(float[] rgb)
Converts a RealColorImage value from RGB to HSV colorspace. R,G,B all (0..255), H (0..360) (or -1 when S == 0), S (0..1), V (0..255)

Parameters:
rgb - RGB value of a RealColorImage

HSVtoRGB

public static float[] HSVtoRGB(float[] hsv)
                        throws NotHSVColorSpaceException
Converts a RealColorImage value from HSV to RGB colorspace. R,G,B all (0..255), H (0..360) (or -1 when S == 0), S (0..1), V (0..255)

Parameters:
hsv - HSV value of a RealColorImage
NotHSVColorSpaceException

RGBtoHLS

public static float[] RGBtoHLS(float[] rgb)
Converts a RealColorImage value from RGB to HLS colorspace. R,G,B all (0..255), H (0..360) (or -1 if S == 0),L (0..255), S (0..1)

Parameters:
rgb - RGB value of a RealColorImage

HLStoRGB

public static float[] HLStoRGB(float[] hls)
                        throws NotHLSColorSpaceException
Converts a RealColorImage value from HLS to RGB colorspace. R,G,B all (0..255), H (0..360) (or -1 if S == 0),L (0..255), S (0..1)

Parameters:
hls - HLS value of a RealColorImage
NotHLSColorSpaceException

RGBtoCMY

public static float[] RGBtoCMY(float[] rgb)
Converts a RealColorImage value from RGB to CMY colorspace. R,G,B,C,M,Y all (0..255)

Parameters:
rgb - RGB value of a RealColorImage

CMYtoRGB

public static float[] CMYtoRGB(float[] cmy)
Converts a RealColorImage value from CMY to RGB colorspace. R,G,B,C,M,Y all (0..255)

Parameters:
cmy - CMY value of a RealColorImage

RGBtoYIQ

public static float[] RGBtoYIQ(float[] rgb)
Converts a RealColorImage value from RGB to YIQ colorspace. R,G,B,Y,I,Q all (0..255)

Parameters:
rgb - RGB value of a RealColorImage

YIQtoRGB

public static float[] YIQtoRGB(float[] yiq)
Converts a RealColorImage value from YIQ to RGB colorspace. R,G,B,Y,I,Q all (0..255)

Parameters:
yiq - YIQ value of a RealColorImage

JIGL
v1.6

Submit a bug or feature
Revised in May 2002 by Weiming Liu