TLIB documentation
 

tlColor.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This file is part of the TLIB computer vision library.
00004 //  Copyright (C) 2003-2008 Sebastien Grange
00005 //  Copyright (C) 2003-2007 VRAI Group, EPFL
00006 //  All rights reserved.
00007 // 
00008 //  This library is free software; you can redistribute it and/or modify
00009 //  it under the terms of the GNU General Public License("GPL") version 2
00010 //  as published by the Free Software Foundation.
00011 // 
00012 //  <http://www.tuyphon.com/tlib>
00013 //
00014 /////////////////////////////////////////////////////////////////////////////////
00015 
00016 
00017 #ifndef __TLCOLOR_H__
00018 #define __TLCOLOR_H__
00019 
00020 
00021 #include "tlVision.h"
00022 
00023 
00024 // convenience defs for draw functions (r,g,b)
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   // color format
00042   tl_format format;
00043 
00044   // raw (unspecified) format
00045   tlPixel raw[TL_MAX_CHANNEL];
00046 
00047   // GRAY format
00048   tlPixel intensity;
00049 
00050   // RGB format
00051   tlPixel r;
00052   tlPixel g;
00053   tlPixel b;
00054 
00055   // YUV format
00056   tlPixel y;
00057   tlPixel u;
00058   tlPixel v;
00059 
00060   // NRG format
00061   tlPixel nr;
00062   tlPixel ng;
00063 
00064   // HSI format
00065   tlPixel h1;
00066   tlPixel h2;
00067   tlPixel s;
00068   tlPixel i;
00069 
00070   
00071   // constructors
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   // management
00081   int copy   (tlColor *color);
00082   int copyTo (tlColor *color);
00083 
00084   // channel manageent
00085   int setChannel   (int channel, tlPixel val);
00086   int swapChannels (int channel1, int channel2);
00087 
00088   // set color from image
00089   int set (tlPixelArray *pixelArray, tlPoint *point);
00090   int set (tlPixelArray *pixelArray, int x, int y);
00091 
00092   // set color from value
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   // set color from image
00100   int setMin  (tlPixelArray *pixelArray, tlRect *rect);
00101   int setMax  (tlPixelArray *pixelArray, tlRect *rect);
00102   int setVar  (tlPixelArray *pixelArray, tlRect *rect);
00103 
00104   // change format (color format conversion)
00105   int toRgb   ();
00106   int toYuv   ();
00107   int toNrg   ();
00108   int toHsi   ();
00109   int toGray  ();
00110   int toBin   (int threshold);
00111 
00112   // add and subtract colors
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 


TLIB documentation - generated on 7 May 2008
Please address any questions to seb@tuyphon.com
(C) 2001-2008 - S. Grange
(C) 2001-2007 - VRAI Group, EPFL
All Rights Reserved.