TLIB documentation
 

tlVision.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 __TLVISION_H__
00018 #define __TLVISION_H__
00019 
00020 
00021 // MS VS2K5 compatibility
00022 #if _MSC_VER >= 1400
00023 #define POINTER_64 __ptr64
00024 #endif
00025 
00026 
00027 // necessary headers
00028 #include <iostream>
00029 #include <stdio.h>
00030 #include <malloc.h>
00031 #define _USE_MATH_DEFINES
00032 #include <math.h>
00033 
00034 using std::cout;
00035 using std::endl;
00036 
00037 // math constants 
00038 #ifndef M_PI
00039 #define TL_PI 3.14159265358979323846 
00040 #else
00041 #define TL_PI M_PI
00042 #endif
00043 
00044 
00045 // constants
00046 #define TL_DEFAULT_COLS   320
00047 #define TL_DEFAULT_ROWS   240
00048 #define TL_MAX_PIXEL_VAL  255
00049 #define TL_MIN_PIXEL_VAL    0
00050 #define TL_MAX_HPIXEL_VAL 65535 /* Hue encoded as 16-bit */
00051 
00052 
00053 // bitmap connectivity
00054 #define TL_NOT_CONNEX   0
00055 #define TL_CONNEX_4     1
00056 #define TL_CONNEX_8     2
00057 
00058 
00059 //
00060 // data type & operations
00061 //
00062 
00063 // two buffer sizes are available: 8bits and 16bits
00064 typedef unsigned char  tlPixel;
00065 typedef short          tlHRPixel;
00066 
00067 typedef int           tlHistData;
00068 #define TL_PIXEL(row,col,width) (((row)*(width))+(col))
00069 #define TL_MIN(a,b)             (((a)<(b))?(a):(b))
00070 #define TL_MAX(a,b)             (((a)>(b))?(a):(b))
00071 #define TL_BOUND(a,x,b)         (TL_MIN(TL_MAX((a),(x)),(b)))
00072 
00073 //
00074 // HSI helper macros
00075 //
00076 
00077 // convert hue MSB and LSB to 16-bit HVAL
00078 #define TL_HMHL_TO_HVAL(hm, hl) (((hm) << 8) | (hl))
00079 
00080 // convert 16-bit HVAL to hue MSB and LSB
00081 #define TL_HVAL_TO_HM(hval) ((hval) >> 8)
00082 #define TL_HVAL_TO_HL(hval) ((hval & 0xff))
00083 
00084 // convert hue: [0,360] deg to scaled 16-bit
00085 #define TL_DEG_TO_HVAL(deg) (unsigned short int) (TL_MAX_HPIXEL_VAL*(deg)/360)
00086 #define TL_HVAL_TO_DEG(hval) (360.0f*(hval)/TL_MAX_HPIXEL_VAL) // float
00087 
00088 // convert saturation: [0,100] percent to [0,TL_MAX_PIXEL_VAL]
00089 #define TL_PCT_TO_SVAL(pct) (tlPixel) (TL_MAX_PIXEL_VAL*(pct)/100)
00090 #define TL_SVAL_TO_PCT(sval) (100.0f*(sval)/TL_MAX_PIXEL_VAL) // float
00091 
00092 // convert intensity: [0,100] percent to [0,TL_MAX_PIXEL_VAL]
00093 #define TL_PCT_TO_IVAL(pct) (tlPixel) (TL_MAX_PIXEL_VAL*(pct)/100)
00094 #define TL_IVAL_TO_PCT(ival) (100.0f*(ival)/TL_MAX_PIXEL_VAL) // float
00095 
00096 
00097 #define TL_PAUSE getc();
00098 
00099 #define TL_NOT_IMPLEMENTED { \
00100   printf ("TL lib error: call to an unimplemented routine\n");  \
00101   return TL_ERROR_NOT_IMPLEMENTED;                              \
00102 }                                                               
00103 
00104 // class list (to make compiler happy)
00105 class tlSize;
00106 class tlLocation;
00107 class tlRect;
00108 class tlPixelArray;
00109 class tlBackground;
00110 class tlBlobs;
00111 class tlHough;
00112 class tlChain;
00113 class tlColor;
00114 class tlColorModel;
00115 template <typename T> class tlConst;
00116 class tlHist;
00117 class tlHist2D;
00118 class tlImage;
00119 class tlLine;
00120 class tlMask;
00121 class tlObject;
00122 class tlPoint;
00123 class tlSpiral;
00124 
00125 
00126 // debug verbosity
00127 extern int tlVerbose;
00128 void tl_set_verbose (int val);
00129 
00130 
00131 
00132 ////////////////////////////////////////////////////////////////////////
00133 // image format
00134 ////////////////////////////////////////////////////////////////////////
00135 
00136 
00137 // typedefs
00138 enum tl_format { RGB, NRG, HSI, YUV, GRAY, BIN, STEREO, CUSTOM };
00139 
00140 // elements per pixel
00141 #define TL_RGB_WIDTH         3
00142 #define TL_NRG_WIDTH         2
00143 #define TL_HSI_WIDTH         4
00144 #define TL_YUV_WIDTH         3
00145 #define TL_GRAY_WIDTH        1
00146 #define TL_BIN_WIDTH         1
00147 #define TL_STEREO_WIDTH      1
00148 
00149 // max allowed dimensions in an image
00150 #define TL_MAX_PIXEL_WIDTH   4
00151 
00152 // get pixel width
00153 inline int tl_pixel_width (tl_format format)
00154 {                                                   
00155   switch(format){
00156   case RGB:    return TL_RGB_WIDTH;
00157   case YUV:    return TL_YUV_WIDTH;
00158   case NRG:    return TL_NRG_WIDTH;
00159   case HSI:    return TL_HSI_WIDTH;
00160   case GRAY:   return TL_GRAY_WIDTH;
00161   case BIN:    return TL_BIN_WIDTH;
00162   case STEREO: return TL_STEREO_WIDTH;
00163   default:
00164     return 0;
00165   }
00166 }
00167 
00168 
00169 // channels
00170 #define TL_CHANNEL_RED      0
00171 #define TL_CHANNEL_GREEN    1
00172 #define TL_CHANNEL_BLUE     2
00173 #define TL_CHANNEL_H        0   /* deprecated. Use TL_CHANNEL_HM */
00174 #define TL_CHANNEL_HM       0   /* MSB */
00175 #define TL_CHANNEL_HL       1   /* LSB */
00176 #define TL_CHANNEL_S        2
00177 #define TL_CHANNEL_I        3
00178 #define TL_CHANNEL_NR       0
00179 #define TL_CHANNEL_NG       1
00180 #define TL_CHANNEL_GRAY     0
00181 #define TL_CHANNEL_BIN      0
00182 #define TL_CHANNEL_STEREO   0
00183 
00184 
00185 ////////////////////////////////////////////////////////////////////////
00186 // headers
00187 ////////////////////////////////////////////////////////////////////////
00188 
00189 
00190 // local headers
00191 #include "tlChannel.h"
00192 #include "tlConvolution.h"
00193 #include "tlEdges.h"
00194 #include "tlError.h"
00195 #include "tlExtract.h"
00196 #include "tlFile.h"
00197 #include "tlFilter.h"
00198 #include "tlFind.h"
00199 #include "tlFormatConversion.h"
00200 #include "tlMemory.h"
00201 #include "tlMorph.h"
00202 #include "tlNormalize.h"
00203 #include "tlPixel.h"
00204 #include "tlScale.h"
00205 #include "tlThread.h"
00206 #include "tlTimer.h"
00207 #include "tlTransforms.h"
00208 
00209 
00210 #ifndef _TLIB_BUILD_
00211 
00212 // class headers
00213 #include "tlSize.h"
00214 #include "tlLocation.h"
00215 #include "tlRect.h"
00216 #include "tlPixelArray.h"
00217 #include "tlBackground.h"
00218 #include "tlBlobs.h"
00219 #include "tlChain.h"
00220 #include "tlColor.h"
00221 #include "tlColorModel.h"
00222 #include "tlConst.h"
00223 #include "tlHist.h"
00224 #include "tlHist2D.h"
00225 #include "tlHough.h"
00226 #include "tlImage.h"
00227 #include "tlLine.h"
00228 #include "tlMask.h"
00229 #include "tlObject.h"
00230 #include "tlPoint.h"
00231 #include "tlSpiral.h"
00232 
00233 #endif
00234 
00235 
00236 
00237 ////////////////////////////////////////////////////////////////////////
00238 // application interface
00239 ////////////////////////////////////////////////////////////////////////
00240 
00241 
00242 extern char *tl_app_name;
00243 int tl_init_lib ();
00244 int tl_init_lib (int argc, char **argv);
00245 
00246 
00247 #endif
00248 


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.