fi.helsinki.cs.ohtu.mpeg2.video
Class RGBToYCbCrConverter

java.lang.Object
  extended by fi.helsinki.cs.ohtu.mpeg2.video.RGBToYCbCrConverter

public class RGBToYCbCrConverter
extends java.lang.Object

A converter from RGB ro YCbCr colour space.


Field Summary
private  double[] coefficients
          The coefficient table to use for this converter.
static double[] ITU_R_BT_470_2_COEFFICIENTS
          If sequence header matrix coefficients value == 5.
static double[] ITU_R_BT_709_COEFFICIENTS
          If sequence header matrix coefficients value == 1.
 
Constructor Summary
RGBToYCbCrConverter()
          Initializes with default coefficients.
RGBToYCbCrConverter(double[] c)
          Initializes with given coefficients.
 
Method Summary
 int[] convert(int red, int green, int blue)
          Converts an RGB value to an YCbCr value.
 void setCoefficients(double[] coefficients)
          Sets the coefficients.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ITU_R_BT_709_COEFFICIENTS

public static final double[] ITU_R_BT_709_COEFFICIENTS
If sequence header matrix coefficients value == 1. The formula for HDTV colour. Best used when creating content to be viewed with flat-panel televisions.


ITU_R_BT_470_2_COEFFICIENTS

public static final double[] ITU_R_BT_470_2_COEFFICIENTS
If sequence header matrix coefficients value == 5. Analogue television systems. Suits best for content geared towards cathode-ray-tube televisions.


coefficients

private double[] coefficients
The coefficient table to use for this converter. TODO:Describe the format of the table.

Constructor Detail

RGBToYCbCrConverter

public RGBToYCbCrConverter()
Initializes with default coefficients. Initializes RGBToYCbCrConverter object and uses ITU_R_BT_709_COEFFICIENTS as the coefficients for conversion.


RGBToYCbCrConverter

public RGBToYCbCrConverter(double[] c)
Initializes with given coefficients.

Parameters:
c - coefficient table to use for conversion.
Method Detail

setCoefficients

public void setCoefficients(double[] coefficients)
Sets the coefficients.

Parameters:
coefficients - array containing the matrix coefficients used in conversion.

convert

public int[] convert(int red,
                     int green,
                     int blue)
Converts an RGB value to an YCbCr value. Performs the conversion from RGB to YCbCr using the coefficients set for this RGBToYCbCrConverter object.

Parameters:
red - RGB red value (0..255)
green - RGB green value (0..255)
blue - RGB blue value (0..255)
Returns:
{y, cb, cr} as an array.