00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __TLCOLOR_H__
00018 #define __TLCOLOR_H__
00019
00020
00021 #include "tlVision.h"
00022
00023
00024
00025 #define TL_COLOR_RED 255, 0, 0
00026 #define TL_COLOR_GREEN 0, 255, 0
00027 #define TL_COLOR_BLUE 0, 0, 255
00028 #define TL_COLOR_WHITE 255, 255, 255
00029 #define TL_COLOR_BLACK 0, 0, 0
00030 #define TL_COLOR_ORANGE 255, 165, 0
00031 #define TL_COLOR_GOLD 255, 215, 0
00032 #define TL_COLOR_PINK 255, 192, 203
00033 #define TL_COLOR_YELLOW 255, 255, 0
00034
00035
00036
00037 class tlColor
00038 {
00039 public:
00040
00041
00042 tl_format format;
00043
00044
00045 tlPixel raw[TL_MAX_CHANNEL];
00046
00047
00048 tlPixel intensity;
00049
00050
00051 tlPixel r;
00052 tlPixel g;
00053 tlPixel b;
00054
00055
00056 tlPixel y;
00057 tlPixel u;
00058 tlPixel v;
00059
00060
00061 tlPixel nr;
00062 tlPixel ng;
00063
00064
00065 tlPixel h1;
00066 tlPixel h2;
00067 tlPixel s;
00068 tlPixel i;
00069
00070
00071
00072 tlColor ();
00073 tlColor (tlColor *src);
00074 tlColor (tlPixel r, tlPixel g, tlPixel b);
00075 tlColor (tlPixel h1, tlPixel h2, tlPixel s, tlPixel i);
00076 tlColor (tlPixel nr, tlPixel ng);
00077 tlColor (tlPixel intensity);
00078 virtual ~tlColor ();
00079
00080
00081 int copy (tlColor *color);
00082 int copyTo (tlColor *color);
00083
00084
00085 int setChannel (int channel, tlPixel val);
00086 int swapChannels (int channel1, int channel2);
00087
00088
00089 int set (tlPixelArray *pixelArray, tlPoint *point);
00090 int set (tlPixelArray *pixelArray, int x, int y);
00091
00092
00093 int setRgb (tlPixel r , tlPixel g , tlPixel b);
00094 int setYuv (tlPixel y , tlPixel u , tlPixel v);
00095 int setNrg (tlPixel nr, tlPixel ng);
00096 int setHsi (tlPixel h1, tlPixel h2, tlPixel s, tlPixel i);
00097 int setGray (tlPixel intensity);
00098
00099
00100 int setMin (tlPixelArray *pixelArray, tlRect *rect);
00101 int setMax (tlPixelArray *pixelArray, tlRect *rect);
00102 int setVar (tlPixelArray *pixelArray, tlRect *rect);
00103
00104
00105 int toRgb ();
00106 int toYuv ();
00107 int toNrg ();
00108 int toHsi ();
00109 int toGray ();
00110 int toBin (int threshold);
00111
00112
00113 int add (tlColor *color);
00114 int add (tlColor *color, tlColor *dest);
00115 int sub (tlColor *color);
00116 int sub (tlColor *color, tlColor *dest);
00117 };
00118
00119
00120 #endif
00121