Sunday, September 28, 2014

How to Convert From RGB to YCrCb in Java

How to Convert From RGB to YCrCb in Java

Instructions

    1

    Define a new function named "RGB_to_YCrCB()" in your Java file.

    void RGB_to_YCrCB (int[] RGB, int[] YCrCB)
    ...

    2

    Calculate the Y value from RGB using the following conversion.

    YCrCb[0] = (int) ( 0.299 RGB[0] + 0.587 RGB[1] + 0.114 * RGB[2]);

    3

    Calculate the Cr value from RGB using the following conversion.

    YCrCb[1] = (int) ( -0.16874 RGB[0] - 0.33126 RGB[1] + 0.50000 * RGB[2]);

    4

    Calculate the Cb value from RGB using the following conversion.

    YCrCb[2] = (int) ( 0.50000 RGB[0] - 0.41869 RGB[1] - 0.08131 * RGB[2]);



No comments:

Post a Comment