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