LoTypes.H

Go to the documentation of this file.
00001 /**
00002    \file Robots/LoBot/misc/LoTypes.H
00003 
00004    \brief Some frequently used types across different parts of all the
00005    Lobot/Robolocust related programs.
00006 */
00007 
00008 // //////////////////////////////////////////////////////////////////// //
00009 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00010 // by the University of Southern California (USC) and the iLab at USC.  //
00011 // See http://iLab.usc.edu for information about this project.          //
00012 // //////////////////////////////////////////////////////////////////// //
00013 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00014 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00015 // in Visual Environments, and Applications'' by Christof Koch and      //
00016 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00017 // pending; application number 09/912,225 filed July 23, 2001; see      //
00018 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00019 // //////////////////////////////////////////////////////////////////// //
00020 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00023 // redistribute it and/or modify it under the terms of the GNU General  //
00024 // Public License as published by the Free Software Foundation; either  //
00025 // version 2 of the License, or (at your option) any later version.     //
00026 //                                                                      //
00027 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00028 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00029 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00030 // PURPOSE.  See the GNU General Public License for more details.       //
00031 //                                                                      //
00032 // You should have received a copy of the GNU General Public License    //
00033 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00034 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00035 // Boston, MA 02111-1307 USA.                                           //
00036 // //////////////////////////////////////////////////////////////////// //
00037 //
00038 // Primary maintainer for this file: mviswana usc edu
00039 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/misc/LoTypes.H $
00040 // $Id: LoTypes.H 13037 2010-03-23 01:00:53Z mviswana $
00041 //
00042 
00043 #ifndef LOBOT_COMMON_TYPES_DOT_H
00044 #define LOBOT_COMMON_TYPES_DOT_H
00045 
00046 //------------------------------ HEADERS --------------------------------
00047 
00048 // lobot headers
00049 #include "Robots/LoBot/util/LoMath.H"
00050 #include "Robots/LoBot/util/triple.hh"
00051 
00052 // INVT image support
00053 #include "Image/Image.H"
00054 #include "Image/PixelsTypes.H"
00055 #include "Image/Point2D.H"
00056 
00057 // Standard C++ headers
00058 #include <limits>
00059 
00060 //----------------------------- NAMESPACE -------------------------------
00061 
00062 namespace lobot {
00063 
00064 //----------------------------- TYPEDEFS --------------------------------
00065 
00066 /// Images captured from the video sources supported by Robolocust will
00067 /// usually have RGB pixels.
00068 ///@{
00069 typedef PixRGB<byte>     PixelType ;
00070 typedef Image<PixelType> ImageType ;
00071 ///@}
00072 
00073 /// Although the "raw" input images are usually RGB and are also
00074 /// visualized in color, most image processing algorithms work with
00075 /// gray-scale images.
00076 typedef Image<float> GrayImage ;
00077 
00078 /// A convenient short-cut.
00079 typedef Point2D<int> Point ;
00080 
00081 //------------------------------ CLASSES --------------------------------
00082 
00083 /// OpenGL colors are represented as a triple of floating point values
00084 /// that lie in the range [0,1].
00085 class GLColor {
00086    float m_color[3] ;
00087 public:
00088    GLColor() ;
00089    GLColor(unsigned char, unsigned char, unsigned char) ;
00090    GLColor(float, float, float) ;
00091    GLColor(const GLColor&) ;
00092    GLColor& operator=(const GLColor&) ;
00093 
00094    //export template<typename T> GLColor(const triple<T, T, T>&) ;
00095    template<typename T> GLColor(const triple<T, T, T>&) ;
00096 
00097    float red()   const {return m_color[0] ;}
00098    float green() const {return m_color[1] ;}
00099    float blue()  const {return m_color[2] ;}
00100    const float* rgb() const {return m_color ;}
00101 } ;
00102 
00103 // Construct from a triple
00104 template<typename T>
00105 GLColor::GLColor(const triple<T, T, T>& t)
00106 {
00107    if (std::numeric_limits<T>::is_integer)
00108    {
00109       m_color[0] = clamp<T>(t.first,  T(0), T(255))/255.0f ;
00110       m_color[1] = clamp<T>(t.second, T(0), T(255))/255.0f ;
00111       m_color[2] = clamp<T>(t.third,  T(0), T(255))/255.0f ;
00112    }
00113    else
00114    {
00115       m_color[0] = static_cast<float>(clamp<T>(t.first,  T(0), T(1))) ;
00116       m_color[1] = static_cast<float>(clamp<T>(t.second, T(0), T(1))) ;
00117       m_color[2] = static_cast<float>(clamp<T>(t.third,  T(0), T(1))) ;
00118    }
00119 }
00120 
00121 //-----------------------------------------------------------------------
00122 
00123 } // end of namespace encapsulating this file's definitions
00124 
00125 #endif
00126 
00127 /* So things look consistent in everyone's emacs... */
00128 /* Local Variables: */
00129 /* indent-tabs-mode: nil */
00130 /* End: */
Generated on Sun May 8 08:05:55 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3