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

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

public class YCbCrToRGBConverter
extends java.lang.Object

A converter from YCbCr to RGB.


Field Summary
private  double[] coefficients
           
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
YCbCrToRGBConverter()
          Initializes with default coefficients.
YCbCrToRGBConverter(double[] c)
          Initializes with given coefficients.
 
Method Summary
 int[] convert(int y, int cb, int cr)
          Converts from yCbCr to RGB.
 void setCoefficients(double[] coefficients)
          Sets 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. Matrix inversion done in freemat(Matlab compatible)


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. Matrix inversion done in freemat(Matlab compatible)


coefficients

private double[] coefficients
Constructor Detail

YCbCrToRGBConverter

public YCbCrToRGBConverter()
Initializes with default coefficients. Initializes the converter and uses ITU_R_BT_709_COEFFICIENTS as the coefficients.


YCbCrToRGBConverter

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

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

setCoefficients

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

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

convert

public int[] convert(int y,
                     int cb,
                     int cr)
Converts from yCbCr to RGB. Performs the conversion from given YCbCr values to RGB using the coefficients set for this YCbCrToRGBConverter object.

Parameters:
y - luminance
cb - blue chrominance
cr - red chrominance
Returns:
{r, g, b} in an array.