Java RGB Color Convert To convertRGBtoYIQ(float[] rgb, float[] yiq)

Here you can find the source of convertRGBtoYIQ(float[] rgb, float[] yiq)

Description

Change an RGB color to YIQ (JPEG) color.

License

LGPL

Parameter

Parameter Description
rgb The array of RGB components to convert
yiq An array to return the colour values with

Declaration

public static void convertRGBtoYIQ(float[] rgb, float[] yiq) 

Method Source Code

//package com.java2s;
/*****************************************************************************
 *                        J3D.org Copyright (c) 2000
 *                               Java Source
 *
 * This source is licensed under the GNU LGPL v2.1
 * Please read http://www.gnu.org/copyleft/lgpl.html for more information
 *
 ****************************************************************************/

public class Main {
    /**/*  ww w  . j a v a2  s . c o  m*/
     * Change an RGB color to YIQ (JPEG) color. The colour value conversion is
     * independent of the colour range. Colours could be 0-1 or 0-255.
     *
     * @param rgb The array of RGB components to convert
     * @param yiq An array to return the colour values with
     */
    public static void convertRGBtoYIQ(float[] rgb, float[] yiq) {
        float r = rgb[0];
        float g = rgb[1];
        float b = rgb[2];

        yiq[0] = (0.299900f * r) + (0.587000f * g) + (0.114000f * b);
        yiq[1] = (0.595716f * r) - (0.274453f * g) - (0.321264f * b);
        yiq[2] = (0.211456f * r) - (0.522591f * g) + (0.311350f * b);
    }
}

Related

  1. convertRgb888To565(int rgb888)
  2. convertRgbaToArgb(int rgba)
  3. convertRgbToByteArray(int[] rgb)
  4. convertRGBtoHSL(int r, int g, int b)
  5. convertRGBtoHSV(float[] rgb, float[] hsv)
  6. rgb24FloatArray(float[] array, int rgb24)
  7. rgb2arr(final int color, final int[] argbarr)
  8. rgb2bilevel(int[] rgb)
  9. rgb2gray(int r, int g, int b)