00001 /*!@file Image/colorDefs.H definitions of a few colors 00002 */ 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2002 // 00005 // by the University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: Laurent Itti <itti@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Image/colorDefs.H $ 00035 // $Id: colorDefs.H 4663 2005-06-23 17:47:28Z rjpeters $ 00036 // 00037 00038 #ifndef COLORDEFS_H_DEFINED 00039 #define COLORDEFS_H_DEFINED 00040 00041 // a few colors by their names 00042 #define COL_BLACK PixRGB<byte>( 0, 0, 0) 00043 #define COL_WHITE PixRGB<byte>(255,255,255) 00044 #define COL_YELLOW PixRGB<byte>(255,255, 0) 00045 #define COL_ORANGE PixRGB<byte>(255,128, 0) 00046 #define COL_BLUE PixRGB<byte>( 0, 0,255) 00047 #define COL_RED PixRGB<byte>(255, 0, 0) 00048 #define COL_GREEN PixRGB<byte>( 0,255, 0) 00049 00050 /* these values come from a statistical analysis 00051 of ~8000 faces in color images 00052 Dirk Walther, 2004 */ 00053 #define COL_SKIN PixRGB<byte>(176,122,107) 00054 #define COL_SKIN_MUR 0.434904 00055 #define COL_SKIN_MUG 0.301983 00056 #define COL_SKIN_SIGR 0.053375 00057 #define COL_SKIN_SIGG 0.024349 00058 #define COL_SKIN_RHO 0.5852 00059 00060 // this value is defined as transparent by convention 00061 #define COL_TRANSPARENT PixRGB<byte>( 1, 1, 1) 00062 00063 // these values are set for MBARI stuff 00064 #define COL_INTERESTING COL_YELLOW 00065 #define COL_CANDIDATE COL_ORANGE 00066 #define COL_SKIP COL_BLUE 00067 #define COL_PREDICTION COL_GREEN 00068 #define COL_FOE COL_RED 00069 00070 const double JPEGYUV_Y_OFFSET = 0.0; 00071 const int JPEGYUV_Y_RANGE = 255; 00072 const double JPEGYUV_UV_OFFSET = 127.5; 00073 const int JPEGYUV_UV_RANGE = 255; 00074 00075 // coeffs from PVRG-JPEG: 00076 // also see http://www.ijg.org/files/jpegsrc.v6b.tar.gz (jdcolor.c) 00077 const double JPEGYUV_RGB_Y = 1.0; 00078 const double JPEGYUV_R_V = 1.402; 00079 const double JPEGYUV_G_U = -0.34414; 00080 const double JPEGYUV_G_V = -0.71414; 00081 const double JPEGYUV_B_U = 1.772; 00082 00083 /* 00084 the rgb2yuv and yuv2rgb conversion matrics are mathematical inverses 00085 of each other: 00086 00087 ._ _. ._ _.(-1) 00088 | | | | 00089 | 1.0000 0 1.4020 | | 0.2990 0.5870 0.1140 | 00090 | 1.0000 -0.3441 -0.7141 | = | -0.1687 -0.3313 0.5000 | 00091 | 1.0000 1.7720 0 | | 0.5000 -0.4187 -0.0813 | 00092 |_ _| |_ _| 00093 */ 00094 00095 const double JPEGYUV_Y_R = 0.29900072215374496; // 0.299 00096 const double JPEGYUV_Y_G = 0.58699836510985282; // 0.587 00097 const double JPEGYUV_Y_B = 0.11400091273640223; // 0.114 00098 const double JPEGYUV_U_R = -0.16873629918382893; // -0.16874 00099 const double JPEGYUV_U_G = -0.33126318572790797; // -0.33126 00100 const double JPEGYUV_U_B = 0.5; // 0.5 00101 const double JPEGYUV_V_R = 0.5; // 0.5 00102 const double JPEGYUV_V_G = -0.41868642304554415; // -0.41869 00103 const double JPEGYUV_V_B = -0.08131306186619276; // -0.08131 00104 00105 /* 00106 see http://www.fourcc.org/fccyvrgb.php 00107 http://www.fourcc.org/fccyvrgb.php#mikes_answer 00108 http://www.siggraph.org/education/materials/HyperGraph/video/mpeg/mpegfaq/ccir601.html 00109 http://www.siggraph.org/education/materials/HyperGraph/video/mpeg/mpegfaq/mpeggloss-y.html 00110 00111 The "natural" range for the luminance (Y) component is [0.0,1.0]. In 00112 jpeg-yuv, that gets mapped to [0,255]. In video-yuv, it gets mapped 00113 to [16,235]. To restore, we subtract VIDEOYUV_Y_OFFSET=16, giving 00114 [0,219], then divide by VIDEOYUV_Y_RANGE=219, giving [0,1]. 00115 00116 The "natural" range for the chrominance (U,V) components is 00117 [-0.5,0.5]. In jpeg-yuv, that gets mapped to [0,255]. In video-yuv, 00118 it gets mapped to [16,240]. To restore, we subtract 00119 VIDEOYUV_UV_OFFSET=128, giving [-112,112], then divide by 00120 VIDEOYUV_UV_RANGE=224, giving [-0.5,0.5]. 00121 */ 00122 00123 const int VIDEOYUV_Y_OFFSET = 16; 00124 const int VIDEOYUV_Y_RANGE = 219; // Y range = [16,235] 00125 const int VIDEOYUV_UV_OFFSET = 128; 00126 const int VIDEOYUV_UV_RANGE = 224; // UV range = [16,240] 00127 00128 const double VIDEOYUV_RGB_Y = JPEGYUV_RGB_Y * (255.0/VIDEOYUV_Y_RANGE); 00129 const double VIDEOYUV_R_V = JPEGYUV_R_V * (255.0/VIDEOYUV_UV_RANGE); 00130 const double VIDEOYUV_G_U = JPEGYUV_G_U * (255.0/VIDEOYUV_UV_RANGE); 00131 const double VIDEOYUV_G_V = JPEGYUV_G_V * (255.0/VIDEOYUV_UV_RANGE); 00132 const double VIDEOYUV_B_U = JPEGYUV_B_U * (255.0/VIDEOYUV_UV_RANGE); 00133 00134 /* 00135 The above conversions should give something like the following: 00136 00137 VIDEOYUV_RGB_Y: 1.16438356164383561 00138 VIDEOYUV_R_V: 1.59602678571428580 00139 VIDEOYUV_G_U: -0.39176651785714289 00140 VIDEOYUV_G_V: -0.81297187500000001 00141 VIDEOYUV_B_U: 2.01723214285714292 00142 */ 00143 00144 const double VIDEOYUV_Y_R = JPEGYUV_Y_R * (VIDEOYUV_Y_RANGE/255.0); 00145 const double VIDEOYUV_Y_G = JPEGYUV_Y_G * (VIDEOYUV_Y_RANGE/255.0); 00146 const double VIDEOYUV_Y_B = JPEGYUV_Y_B * (VIDEOYUV_Y_RANGE/255.0); 00147 const double VIDEOYUV_U_R = JPEGYUV_U_R * (VIDEOYUV_UV_RANGE/255.0); 00148 const double VIDEOYUV_U_G = JPEGYUV_U_G * (VIDEOYUV_UV_RANGE/255.0); 00149 const double VIDEOYUV_U_B = JPEGYUV_U_B * (VIDEOYUV_UV_RANGE/255.0); 00150 const double VIDEOYUV_V_R = JPEGYUV_V_R * (VIDEOYUV_UV_RANGE/255.0); 00151 const double VIDEOYUV_V_G = JPEGYUV_V_G * (VIDEOYUV_UV_RANGE/255.0); 00152 const double VIDEOYUV_V_B = JPEGYUV_V_B * (VIDEOYUV_UV_RANGE/255.0); 00153 00154 #endif 00155 00156 // ###################################################################### 00157 /* So things look consistent in everyone's emacs... */ 00158 /* Local Variables: */ 00159 /* indent-tabs-mode: nil */ 00160 /* End: */