|
Urbi SDK Remote for Java
2.7.5
|
00001 /* 00002 * Copyright (C) 2010-2011, Gostai S.A.S. 00003 * 00004 * This software is provided "as is" without warranty of any kind, 00005 * either expressed or implied, including but not limited to the 00006 * implied warranties of fitness for a particular purpose. 00007 * 00008 * See the LICENSE file for more information. 00009 */ 00010 00011 package urbi; 00012 00013 /** 00014 * The ImageFilter class is a useful class to obtain the RGB and YCrCb values of 00015 * a given color. 00016 * <p> 00017 * <p> 00018 * @author Bastien Saltel 00019 */ 00020 00021 public class ImageFilter 00022 { 00023 /** 00024 * Returns the Red value of the color. 00025 * <p> 00026 * @param color The given color. 00027 * @return The Red value 00028 */ 00029 public static double getRed(int color) 00030 { 00031 return (color >> 16) & 0xFF; 00032 } 00033 00034 /** 00035 * Returns the Green value of the color. 00036 * <p> 00037 * @param color The given color. 00038 * @return The Green value 00039 */ 00040 public static double getGreen(int color) 00041 { 00042 return (color >> 8) & 0xFF; 00043 } 00044 00045 /** 00046 * Returns the Blue value of the color. 00047 * <p> 00048 * @param color The given color. 00049 * @return The Blue value 00050 */ 00051 public static double getBlue(int color) 00052 { 00053 return color & 0xFF; 00054 } 00055 00056 /** 00057 * Returns the Y value of the color. 00058 * <p> 00059 * @param color The given color. 00060 * @return The Y value 00061 */ 00062 public static double getY(int color) 00063 { 00064 return (0.299 * getRed(color) + 0.587 * getGreen(color) + 0.114 * getBlue(color)); 00065 } 00066 00067 /** 00068 * Returns the Cr value of the color. 00069 * <p> 00070 * @param color The given color. 00071 * @return The Cr value 00072 */ 00073 public static double getCr(int color) 00074 { 00075 return (0.500 * getRed(color) - 0.419 * getGreen(color) - 0.081 * getBlue(color)); 00076 } 00077 00078 /** 00079 * Returns the Cb value of the color. 00080 * <p> 00081 * @param color The given color. 00082 * @return The Cb value 00083 */ 00084 public static double getCb(int color) 00085 { 00086 return (-0.169 * getRed(color) - 0.331 * getGreen(color) + 0.500 * getBlue(color)); 00087 } 00088 }