TLIB documentation
 

tlPixelArray.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 __TLPIXELARRAY_H__
00018 #define __TLPIXELARRAY_H__
00019 
00020 
00021 #include "tlVision.h"
00022 #include "tlRect.h"
00023 
00024 
00025 class tlPixelArray : public tlRect
00026 {
00027 protected:  
00028   int create      (tl_format format, int width, int height);
00029   int deletePixel ();
00030 
00031 public:
00032 
00033   tl_format       format;
00034   unsigned long   timeStamp;
00035   int             pixelWidth;
00036   bool            hr;
00037   unsigned char   hrShift;
00038   tlHRPixel*      hrpixel;
00039   tlPixel*        pixel;
00040 
00041 
00042   // constructors
00043   tlPixelArray  ();
00044   tlPixelArray  (tl_format format, int width, int height);
00045   tlPixelArray  (tlPixelArray *pixelArray);
00046   virtual ~tlPixelArray ();
00047 
00048   // initialization
00049   int init (tlPixelArray *pixelArray);
00050   int init (tl_format format, int width, int height);
00051   int init (int width, int height, int pixelWidth);
00052 
00053   // data access
00054   int setPixel (int val, int x, int y, int channel=0);
00055   int setPixel (int val, tlPoint *point, int channel=0);
00056   int getPixel (int x, int y, int channel=0);
00057   int getPixel (tlPoint *point, int channel=0);
00058   
00059   // copy and format
00060   int     copy   (tlPixelArray *pixelArray);
00061   int     copy   (tlPixelArray *pixelArray, tlRect *rect);
00062   int     copyTo (tlPixelArray *pixelArray);
00063   int     copyTo (tlPixelArray *pixelArray, tlRect *rect);
00064   int     toRect (tlRect *rect);
00065   tlRect* toRect ();
00066 
00067   // scale
00068   int scale (float factor, int method=TL_SCALE_DECIMATE);
00069   int scale (int newWidth, int newHeight, int method=TL_SCALE_DECIMATE);
00070   int scale (float factor, tlPixelArray *dest, int method=TL_SCALE_DECIMATE);
00071   int scale (int newWidth, int newHeight, tlPixelArray *dest, int method=TL_SCALE_DECIMATE);
00072 
00073   // clear
00074   int clear (void);
00075   int clear (tlRect *rect);
00076 
00077   // channel management
00078   int addChannel    ();
00079   int remChannel    (int channel);
00080   int toChannel     (int channel);
00081   int toChannel     (int channel, tlRect *rect);
00082   int putChannel    (tlPixel *pixelArray, int channel);
00083   int putChannel    (tlPixel *pixelArray, tlRect *rect, int channel);
00084   int putChannel    (tlPixelArray *pixelArray, int channel);
00085   int putChannel    (tlPixelArray *pixelArray, tlRect *rect, int channel);
00086   int swapChannels  (int channel1, int channel2);
00087 
00088   // channel management to new images
00089   int remChannel    (int channel, tlPixelArray *dest);
00090   int toChannel     (int channel, tlPixelArray *dest);
00091   int toChannel     (int channel, tlRect *rect, tlPixelArray *dest);
00092   int putChannel    (tlPixel *pixelArray, int channel, tlPixelArray *dest);
00093   int putChannel    (tlPixel *pixelArray, tlRect *rect, int channel, tlPixelArray *dest);
00094   int putChannel    (tlPixelArray *pixelArray, int channel, tlPixelArray *dest);
00095   int putChannel    (tlPixelArray *pixelArray, tlRect *rect, int channel, tlPixelArray *dest);
00096   int swapChannels  (int channel1, int channel2, tlPixelArray *dest);
00097 
00098   // format changes
00099   int toRgb     ();
00100   int toRgb     (tlRect *rect);
00101   int toYuv     ();
00102   int toYuv     (tlRect *rect);
00103   int toNrg     ();
00104   int toNrg     (tlRect *rect);
00105   int toHsi     ();
00106   int toHsi     (tlRect *rect);
00107   int toGray    ();
00108   int toGray    (tlRect *rect);
00109   int toBin     (int threshold = 1);
00110   int toBin     (int threshold, tlRect *rect);
00111   int toBin     (int min, int max);
00112   int toBin     (int min, int max, tlRect *rect);
00113 
00114   // copy to new images
00115   int toRgb     (tlPixelArray *dest);
00116   int toRgb     (tlRect *rect, tlPixelArray *dest);
00117   int toYuv     (tlPixelArray *dest);
00118   int toYuv     (tlRect *rect, tlPixelArray *dest);
00119   int toNrg     (tlPixelArray *dest);
00120   int toNrg     (tlRect *rect, tlPixelArray *dest);
00121   int toHsi     (tlPixelArray *dest);
00122   int toHsi     (tlRect *rect, tlPixelArray *dest);
00123   int toGray    (tlPixelArray *dest);
00124   int toGray    (tlRect *rect, tlPixelArray *dest);
00125   int toBin     (int threshold, tlPixelArray *dest);
00126   int toBin     (int threshold, tlRect *rect, tlPixelArray *dest);
00127   int toBin     (int min, int max, tlPixelArray *dest);
00128   int toBin     (int min, int max, tlRect *rect, tlPixelArray *dest);
00129   
00130   // image masking
00131   int mask (tlRect *rect);
00132   int mask (tlPixelArray *mask);
00133   int mask (tlPixelArray *mask, tlRect *rect);
00134   int mask (tlRect *rect, tlPixelArray *dest);
00135         int mask (tlPixelArray *mask, tlPixelArray *dest);
00136   int mask (tlPixelArray *mask, tlRect *rect, tlPixelArray *dest);
00137 
00138   // image subtracting/adding
00139   int add (tlPixelArray *pixelArray);
00140   int add (tlPixelArray *pixelArray, tlRect *rect);
00141   int add (tlPixelArray *pixelArray, tlPixelArray *dest);
00142   int add (tlPixelArray *pixelArray, tlRect *rect, tlPixelArray *dest);
00143   int sub (tlPixelArray *pixelArray);
00144   int sub (tlPixelArray *pixelArray, tlRect *rect);
00145   int sub (tlPixelArray *pixelArray, tlPixelArray *dest);
00146   int sub (tlPixelArray *pixelArray, tlRect *rect, tlPixelArray *dest);
00147 
00148   // convolution
00149   int convolution (char  *kernel,  int kernel_size);
00150   int convolution (char  *kernel,  int kernel_width, int kernel_height);
00151   int convolution (float *kernel,  int kernel_size);
00152   int convolution (float *kernel,  int kernel_width, int kernel_height);
00153   int convolution (char  *kernel,  int kernel_size,  tlRect *rect);
00154   int convolution (char  *kernel,  int kernel_width, int kernel_height, tlRect *rect);
00155   int convolution (float *kernel,  int kernel_size,  tlRect *rect);
00156   int convolution (float *kernel,  int kernel_width, int kernel_height, tlRect *rect);
00157   int convolution (char  *xkernel, int xksize, char  *ykernel, int yksize);
00158   int convolution (char  *xkernel, int xksize, char  *ykernel, int yksize, tlRect *rect);
00159   int convolution (float *xkernel, int xksize, float *ykernel, int yksize);
00160   int convolution (float *xkernel, int xksize, float *ykernel, int yksize, tlRect *rect);
00161 
00162   // convolution to a new image
00163   int convolution (char  *kernel,  int kernel_size,  tlPixelArray *dest);
00164   int convolution (char  *kernel,  int kernel_width, int kernel_height, tlPixelArray *dest);
00165   int convolution (float *kernel,  int kernel_size,  tlPixelArray *dest);
00166   int convolution (float *kernel,  int kernel_width, int kernel_height, tlPixelArray *dest);
00167   int convolution (char  *kernel,  int kernel_size,  tlRect *rect, tlPixelArray *dest);
00168   int convolution (char  *kernel,  int kernel_width, int kernel_height, tlRect *rect, tlPixelArray *dest);
00169   int convolution (float *kernel,  int kernel_size,  tlRect *rect, tlPixelArray *dest);
00170   int convolution (float *kernel,  int kernel_width, int kernel_height, tlRect *rect, tlPixelArray *dest);
00171   int convolution (char  *xkernel, int xksize, char  *ykernel, int yksize, tlPixelArray *dest);
00172   int convolution (char  *xkernel, int xksize, char  *ykernel, int yksize, tlRect *rect, tlPixelArray *dest);
00173   int convolution (float *xkernel, int xksize, float *ykernel, int yksize, tlPixelArray *dest);
00174   int convolution (float *xkernel, int xksize, float *ykernel, int yksize, tlRect *rect, tlPixelArray *dest);
00175   int convolution (float *xkernel, int xksize, float *ykernel, int yksize, tlRect *rect, tlPixelArray *mask, tlPixelArray *dest);
00176 
00177   // filters
00178   int median (int size);
00179   int median (int size, tlRect *rect);
00180 
00181   // morph processing
00182   int erode   (int size);
00183   int erode   (int size, tlRect *rect);
00184   int erode   (tlMask *shape);
00185   int erode   (tlMask *shape, tlRect *rect);
00186   int dilate  (int size);
00187   int dilate  (int size, tlRect *rect);
00188   int dilate  (tlMask *shape);
00189   int dilate  (tlMask *shape, tlRect *rect);
00190   int opening (int size);
00191   int opening (int size, tlRect *rect);
00192   int opening (tlMask *shape);
00193   int opening (tlMask *shape, tlRect *rect);
00194   int closing (int size);
00195   int closing (int size, tlRect *rect);
00196   int closing (tlMask *shape);
00197   int closing (tlMask *shape, tlRect *rect);
00198   int thin    ();
00199   int thin    (tlRect *rect);
00200 
00201   // morph processing to a new image
00202   int erode   (int size, tlPixelArray *dest);
00203   int erode   (int size, tlRect *rect, tlPixelArray *dest);
00204   int dilate  (int size, tlPixelArray *dest);
00205   int dilate  (int size, tlRect *rect, tlPixelArray *dest);
00206   int opening (int size, tlPixelArray *dest);
00207   int opening (int size, tlRect *rect, tlPixelArray *dest);
00208   int closing (int size, tlPixelArray *dest);
00209   int closing (int size, tlRect *rect, tlPixelArray *dest);
00210   int thin    (tlPixelArray *dest);
00211   int thin    (tlRect *rect, tlPixelArray *dest);
00212 
00213   // monochrome filtering
00214   int filter (int minVal, int maxVal);
00215   int filter (int minVal, int maxVal, tlRect *rect);
00216   int filter (int minVal, int maxVal, tlPixelArray *dest);
00217   int filter (int minVal, int maxVal, tlRect *rect, tlPixelArray *dest);
00218 
00219   // color filtering
00220   int filter (tlColor *minColor, tlColor *maxColor);
00221   int filter (tlColor *minColor, tlColor *maxColor, tlRect *rect);
00222   int filter (tlColor *minColor, tlColor *maxColor, tlPixelArray *dest);
00223   int filter (tlColor *minColor, tlColor *maxColor, tlRect *rect, tlPixelArray *dest);
00224 
00225   // data
00226   int getMax      (tlMask *mask, tlPoint *point, int channel = 0);
00227   int getMin      (tlMask *mask, tlPoint *point, int channel = 0);
00228 
00229   // color extraction
00230   int getColor    (tlPoint *point, tlColor *color);
00231   int getColor    (int x, int y, tlColor *color);
00232   int getColors   (tlColor *minColor, tlColor *maxColor);
00233   int getColors   (tlColor *minColor, tlColor *maxColor, tlRect *rect);
00234   int getColorMin (tlColor *minColor);
00235   int getColorMin (tlColor *minColor, tlRect *rect);
00236   int getColorMax (tlColor *maxColor);
00237   int getColorMax (tlColor *maxColor, tlRect *rect);
00238 
00239   // object/shape matching
00240   int find          (tlObject *object, int confidence, int increment = TL_DEFAULT_INCREMENT);
00241   int find          (tlObject *object, int confidence, tlRect *rect, int increment = TL_DEFAULT_INCREMENT);
00242   int findBest      (tlObject *object, int increment = TL_DEFAULT_INCREMENT);
00243   int findBest      (tlObject *object, tlRect *rect, int increment = TL_DEFAULT_INCREMENT);
00244   int find          (tlMask   *shape,  int confidence, int increment = TL_DEFAULT_INCREMENT);
00245   int find          (tlMask   *shape,  int confidence, tlRect *rect, int increment = TL_DEFAULT_INCREMENT);
00246   int findBest      (tlMask   *shape,  int increment = TL_DEFAULT_INCREMENT);
00247   int findBest      (tlMask   *shape,  tlRect *rect, int increment = TL_DEFAULT_INCREMENT);
00248   int findShape     (tlObject *object, int confidence, int increment = TL_DEFAULT_INCREMENT);
00249   int findShape     (tlObject *object, int confidence, tlRect *rect, int increment = TL_DEFAULT_INCREMENT);
00250   int findBestShape (tlObject *object, int increment = TL_DEFAULT_INCREMENT);
00251   int findBestShape (tlObject *object, tlRect *rect, int increment = TL_DEFAULT_INCREMENT);
00252 
00253   // histogram management
00254   int buildHist (tlHist *hist, int channel=0);
00255   int buildHist (tlHist *hist, tlRect *rect, int channel=0);
00256   int buildHist (tlHist *hist, tlMask *mask, int channel=0);
00257   int buildHist (tlHist *hist, tlMask *mask, tlRect *rect, int channel=0);
00258 
00259   // 2D histogram management
00260   int buildHist (tlHist2D *hist, int xchannel=0, int ychannel = 1);
00261   int buildHist (tlHist2D *hist, tlRect *rect, int xchannel=0, int ychannel = 1);
00262   int buildHist (tlHist2D *hist, tlMask *mask, int xchannel=0, int ychannel = 1);
00263   int buildHist (tlHist2D *hist, tlMask *mask, tlRect *rect, int xchannel=0, int ychannel = 1);
00264 };
00265 
00266 
00267 #endif


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.