00001 /*!@file Video/RgbConversion.H Raw conversion between video formats and RGB images */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 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: Rob Peters <rjpeters at usc dot edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Video/RgbConversion.H $ 00035 // $Id: RgbConversion.H 12660 2010-01-26 02:14:54Z beobot $ 00036 // 00037 00038 #ifndef VIDEO_RGBCONVERSION_H_DEFINED 00039 #define VIDEO_RGBCONVERSION_H_DEFINED 00040 00041 #include "Util/Types.H" // for byte 00042 #include "Raster/DeBayer.H" 00043 00044 #include <cstdlib> // for size_t 00045 00046 class Dims; 00047 template <class T> class Image; 00048 template <class T> class PixRGB; 00049 00050 //! Build an RGB image from an RGB C array, with optional byte-swapping 00051 /*! If byte-swapping is off, this will just perform a deep copy of the 00052 data; this function is somewhat redundant with the Image 00053 constructor and is provided for completeness with respect to the 00054 fromXXX methods only. Note that data should have 00055 3*dims.w()*dims.h() elements, and it is the responsibility of the 00056 caller to free that data later. */ 00057 template <class T> 00058 Image<PixRGB<T> > fromRGB(const T* data, const size_t length, 00059 const Dims& dims, const bool byteswap); 00060 00061 //! Build an RGB image from a alpha+RGB C array, with optional byte-swapping 00062 template <class T> 00063 Image<PixRGB<T> > fromARGB(const T* data, const size_t length, 00064 const Dims& dims, const bool byteswap); 00065 00066 //! Build an RGB image from an RGB555 C array, with optional byte-swapping 00067 Image<PixRGB<byte> > fromRGB555(const byte* data, const size_t length, 00068 const Dims& dims, const bool byteswap); 00069 00070 //! Build an RGB image from an RGB565 C array, with optional byte-swapping 00071 Image<PixRGB<byte> > fromRGB565(const byte* data, const size_t length, 00072 const Dims& dims, const bool byteswap); 00073 00074 //! Build an RGB image from a YUV24 C array, with optional byte-swapping 00075 template <class T> 00076 Image<PixRGB<T> > fromVideoYUV24(const T* data, const size_t length, 00077 const Dims& dims, const bool byteswap); 00078 00079 //! Build an RGB image from a YUV444 C array, with optional byte-swapping 00080 template <class T> 00081 Image<PixRGB<T> > fromVideoYUV444(const T* data, const size_t length, 00082 const Dims& dims, const bool byteswap); 00083 00084 //! Build an RGB image from a YUV422 C array, with optional byte-swapping 00085 template <class T> 00086 Image<PixRGB<T> > fromVideoYUV422(const T* data, const size_t length, 00087 const Dims& dims, const bool byteswap); 00088 00089 //! Build an RGB image from a YUV411 C array, with optional byte-swapping 00090 template <class T> 00091 Image<PixRGB<T> > fromVideoYUV411(const T* data, const size_t length, 00092 const Dims& dims, const bool byteswap); 00093 00094 //! Build an RGB image from a YUV422-planar C array 00095 template <class T> 00096 Image<PixRGB<T> > fromVideoYUV444P(const T* data, const size_t length, 00097 const Dims& dims); 00098 00099 //! Build an RGB image from a YUV422-planar C array 00100 template <class T> 00101 Image<PixRGB<T> > fromVideoYUV422P(const T* data, const size_t length, 00102 const Dims& dims); 00103 00104 //! Build an RGB image from a YUV411-planar C array 00105 template <class T> 00106 Image<PixRGB<T> > fromVideoYUV411P(const T* data, const size_t length, 00107 const Dims& dims); 00108 00109 //! Build an RGB image from a YUV420-planar C array 00110 template <class T> 00111 Image<PixRGB<T> > fromVideoYUV420P(const T* data, const size_t length, 00112 const Dims& dims); 00113 00114 //! Build an RGB image from a HM12-planar C array 00115 template <class T> 00116 Image<PixRGB<T> > fromVideoHM12(const T* data, const size_t length, 00117 const Dims& dims); 00118 00119 //! Build an RGB image from a motion compressed jpeg 00120 template <class T> 00121 Image<PixRGB<T> > fromVideoMJPEG(const T* data, const size_t length, 00122 const Dims& dims); 00123 00124 //! Build an RGB image from a YUV410-planar C array 00125 template <class T> 00126 Image<PixRGB<T> > fromVideoYUV410P(const T* data, const size_t length, 00127 const Dims& dims); 00128 00129 //! Build an RGB image from a grayscale C array of size dims.w()*dims.h() 00130 template <class T> 00131 Image<PixRGB<T> > fromMono(const T* data, const size_t length, 00132 const Dims& dims); 00133 00134 //! Build an RGB image from a bayer C array 00135 Image<PixRGB<byte> > fromBayer(const byte* data, const size_t length, 00136 const Dims& dims, BayerFormat ft); 00137 00138 Image<PixRGB<uint16> > fromBayerU16(const uint16* data, const size_t length, 00139 const Dims& dims, BayerFormat ft); 00140 00141 //! Fill pre-allocated YUV422 C arrays with values from an image 00142 void toVideoYUV422(const Image<PixRGB<byte> > img, 00143 byte* y, byte* u, byte* v, 00144 const int ystride = 0, 00145 const int ustride = 0, 00146 const int vstride = 0); 00147 00148 // ###################################################################### 00149 /* So things look consistent in everyone's emacs... */ 00150 /* Local Variables: */ 00151 /* mode: c++ */ 00152 /* indent-tabs-mode: nil */ 00153 /* End: */ 00154 00155 #endif // VIDEO_RGBCONVERSION_H_DEFINED