Here you can find the source of rgb2xyz(double[] RGB)
Parameter | Description |
---|---|
RGB | red, green and blue components, in the range from 0 to 1 |
public static double[] rgb2xyz(double[] RGB)
//package com.java2s; /*************************************** * ViPER * * The Video Processing * * Evaluation Resource * * * * Distributed under the GPL license * * Terms available at gnu.org. * * * * Copyright University of Maryland, * * College Park. * ***************************************/ public class Main { /**//from ww w . j ava 2 s. com * Converts from the given RGB triplet into a corresponding * XYZ triplet. * @param RGB red, green and blue components, in the range from 0 to 1 * @return the XYZ color components */ public static double[] rgb2xyz(double[] RGB) { double[] xyz = new double[3]; double[] rgb = new double[3]; System.arraycopy(RGB, 0, rgb, 0, 3); for (int i = 0; i < 3; i++) { if (rgb[i] > 0.04045) { rgb[i] = Math.pow((rgb[i] + 0.055) / 1.055, 2.4); } else { rgb[i] = rgb[i] / 12.92; } } xyz[0] = rgb[0] * 0.4124 + rgb[1] * 0.3576 + rgb[2] * 0.1805; xyz[1] = rgb[0] * 0.2126 + rgb[1] * 0.7152 + rgb[2] * 0.0722; xyz[2] = rgb[0] * 0.0193 + rgb[1] * 0.1192 + rgb[2] * 0.9505; return xyz; } }