TLIB documentation
 

tlHist2D.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 __TLHISTOGRAM2D_H__
00018 #define __TLHISTOGRAM2D_H__
00019 
00020 
00021 #include "tlVision.h"
00022 
00023 
00024 
00025 class tlHist2D
00026 {
00027 private:
00028 
00029   int         xLength;    // histogram length (i.e. number of elements) on X
00030   int         yLength;    // histogram length (i.e. number of elements) on Y
00031   int         xOffset;    // data offset (i.e. first index) on X
00032   int         yOffset;    // data offset (i.e. first index) on Y
00033   int         xMin;                             // X index of min value
00034   int         xMax;                             // X index of max value
00035   int         yMin;                             // Y index of min value
00036   int         yMax;                             // Y index of max value
00037   tlHistData  minVal;                   // min value
00038   tlHistData  maxVal;                   // max value
00039 
00040   int create      (int xlength, int ylength, int xoffset, int yoffset);
00041   int deleteData  ();
00042 
00043 public:
00044 
00045   int         xChannel;   // for information only
00046   int         yChannel;   // for information only
00047   tlHistData  **data;                   // pointer to histogram data
00048   tlHistData  *xRank;     // pointer to histogram ranking information
00049   tlHistData  *yRank;     // pointer to histogram ranking information
00050 
00051     
00052   // constructors
00053   tlHist2D  ();
00054   tlHist2D  (int length);
00055   tlHist2D  (int xlength, int ylength, int xoffset = 0, int yoffset = 0);
00056   virtual ~tlHist2D ();
00057 
00058   // file read/write
00059   int save (char *filename);
00060   int load (char *filename);
00061 
00062   // initialization
00063   int   init       (int length);
00064   int   init       (int xlength, int ylength, int xoffset = 0, int yoffset = 0);
00065   int   clear      ();
00066   int   update     ();
00067   int   updateRank ();
00068 
00069   // set data
00070   int   setXChannel (int channel);
00071   int   setYChannel (int channel);
00072 
00073   // read data
00074   int   getVal        (int x, int y);
00075   int   getXRank      (int index);
00076   int   getYRank      (int index);
00077   int   getMaxVal     () { return maxVal; };
00078   int   getMinVal     () { return minVal; };
00079   int   getXOffset    () { return xOffset; };
00080   int   getXLength    () { return xLength; };
00081   int   getXMaxIndex  () { return xMax;    };
00082   int   getXMinIndex  () { return xMin;    };
00083   int   getYOffset    () { return yOffset; };
00084   int   getYLength    () { return yLength; };
00085   int   getYMaxIndex  () { return yMax;    };
00086   int   getYMinIndex  () { return yMin;    };
00087 
00088   // set data
00089   int   setVal (int x, int y, tlHistData val);
00090   int   incVal (int x, int y);
00091   int   decVal (int x, int y);
00092 
00093   // normalize [% peak]
00094   int   normalize (int max = 100);
00095 
00096   // normalize [% sum]
00097   int   integrate (int sum = 100);
00098 
00099   // compare
00100   float compare (tlHist2D *hist);
00101 
00102   // build histogram
00103   int   build (tlPixel *xdata, tlPixel *ydata, int len);
00104   int   build (tlPixel *xdata, tlPixel *ydata, int len, int xlength, int ylength, int xoffset = 0, int yoffset = 0);
00105   int   build (tlPixel *src, int width, int height, int pixelWidth, tlPixel *mask, int xchannel, int ychannel, tlRect *rect);
00106 
00107   // build histogram from high-resolution images
00108   int   build (tlHRPixel *xdata, tlHRPixel *ydata, int len);
00109   int   build (tlHRPixel *xdata, tlHRPixel *ydata, int len, int xlength, int ylength, int xoffset = 0, int yoffset = 0);
00110 
00111   // project to 1D histograms
00112   int     getXHist (tlHist *hist);
00113   int     getYHist (tlHist *hist);
00114   tlHist *getXHist ();
00115   tlHist *getYHist ();
00116 
00117   // project to image
00118   int     toImage  (tlImage *image);
00119   tlImage *toImage ();
00120 };
00121 
00122 #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.