Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

colors.h

Go to the documentation of this file.
00001 #ifndef __COLORS_H__
00002 #define __COLORS_H__
00003 
00004 /*! @file
00005 * @brief Color definitions for #CMVision
00006 * @author James R. Bruce, School of Computer Science, Carnegie Mellon University
00007 *
00008 * Licensed under the <a href="../gpl-2.0.txt">GNU GPL version 2</a>
00009 */
00010 
00011 typedef unsigned int color_index;
00012 
00013 //==== Color Classes =================================================//
00014 namespace CMVision{
00015   typedef unsigned char uchar;
00016 }
00017 
00018 #ifndef YUV_STRUCT
00019 #define YUV_STRUCT
00020 struct yuv{
00021   CMVision::uchar y,u,v;
00022   yuv() : y(0), u(0), v(0) {}
00023   yuv(int yval, int uval, int vval) : y(yval), u(uval), v(vval) {}
00024 };
00025 
00026 /* Deprecated
00027 struct yuv_int{
00028   int y,u,v;
00029 };
00030 */
00031 #endif
00032 
00033 #ifndef YUVI_STRUCT
00034 #define YUVI_STRUCT
00035 struct yuvi{
00036   int y,u,v;
00037 };
00038 #endif
00039 
00040 #ifndef YUVF_STRUCT
00041 #define YUVF_STRUCT
00042 struct yuvf{
00043   float y,u,v;
00044 };
00045 #endif
00046 
00047 #ifndef YUYV_STRUCT
00048 #define YUYV_STRUCT
00049 struct yuyv{
00050   CMVision::uchar y1,u,y2,v;
00051 };
00052 #endif
00053 
00054 struct uyvy{
00055 #ifndef UYVY_STRUCT
00056 #define UYVY_STRUCT
00057   CMVision::uchar u,y1,v,y2;
00058 };
00059 #endif
00060 
00061 #ifndef RGB_STRUCT
00062 #define RGB_STRUCT
00063 struct rgb{
00064   CMVision::uchar red,green,blue;
00065 
00066   rgb() : red(0), green(0), blue(0) {};
00067 
00068   rgb(int r, int g, int b)
00069     : red((CMVision::uchar)r), green((CMVision::uchar)g), blue((CMVision::uchar)b)
00070   { };
00071        
00072 
00073   bool operator ==(const rgb &x) const {
00074     return (red  ==x.red   &&
00075             green==x.green &&
00076             blue ==x.blue);
00077   }
00078 
00079   bool operator !=(const rgb &x) const {
00080     return !operator==(x);
00081   }
00082 };
00083 #endif
00084 
00085 #ifndef RGBA_STRUCT
00086 #define RGBA_STRUCT
00087 struct rgba{
00088   CMVision::uchar r,g,b,a;
00089 };
00090 #endif
00091 
00092 #ifndef ARGB_STRUCT
00093 #define ARGB_STRUCT
00094 struct argb{
00095   CMVision::uchar a,r,g,b;
00096 };
00097 #endif
00098 
00099 #ifndef RGBF_STRUCT
00100 #define RGBF_STRUCT
00101 struct rgbf{
00102   float red,green,blue;
00103 
00104   rgbf()
00105     : red(0),green(0),blue(0) {}
00106   rgbf(float nred,float ngreen,float nblue)
00107     : red(nred),green(ngreen),blue(nblue) {}
00108 
00109 };
00110 #endif
00111 
00112 #ifndef RGBAF_STRUCT
00113 #define RGBAF_STRUCT
00114 struct rgbaf{
00115   float r,g,b,a;
00116 };
00117 #endif
00118 
00119 #ifndef ARGBF_STRUCT
00120 #define ARGBF_STRUCT
00121 struct argbf{
00122   float a,r,g,b;
00123 };
00124 #endif
00125 
00126 yuv rgb2yuv(const rgb x);
00127 
00128 //==== converting rgb and yuv to string
00129 #include <iostream>
00130 #include <string>
00131 
00132 std::ostream& operator<<(std::ostream &os, const rgb &rgbval);
00133 std::string toString(const rgb &rgbval);
00134 
00135 std::ostream& operator<<(std::ostream &os, const yuv &yuvval);
00136 std::string toString(const yuv &yuvval);
00137 
00138 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:37 2016 by Doxygen 1.6.3