Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

phHistogramData.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission :
00003         Realtime Vision Processing System
00004 
00005     Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008 
00009     This file is part of Phission.
00010 
00011     Phission is free software; you can redistribute it and/or modify
00012     it under the terms of the GNU Lesser General Public License as published by
00013     the Free Software Foundation; either version 2 of the License, or
00014     (at your option) any later version.
00015 
00016     Phission is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU Lesser General Public License for more details.
00020 
00021     You should have received a copy of the GNU Lesser General Public License
00022     along with Phission; if not, write to the Free Software
00023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025  ---------------------------------------------------------------------------*/
00026 #ifndef _PHHISTOGRAMDATA_H
00027 #define _PHHISTOGRAMDATA_H
00028 
00034 #include <ImageDefinitions.h>
00035 #include <ImageGfx.h>
00036 #include <phLiveObject.h>
00037 #include <phImage.h>
00038 
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047 
00048 /* This computes the histogram from the image data and dimensions.
00049  * The bin arrays are allocated and returned using the pointers. */
00054 int ph_histogram_data_gen_from_image(const uint32_t width,
00055                                      const uint32_t height,
00056                                      const uint32_t depth,
00057                                      const uint8_t  *img,
00058                                      
00059                                      uint32_t x1,
00060                                      uint32_t y1,
00061                                      uint32_t x2,
00062                                      uint32_t y2,
00063                                      
00064                                      const uint32_t nbins,
00065                                      const float    max_element_value,
00066                                      uint32_t       **pbinVal,
00067                                      uint32_t       *pbinVal_size,
00068                                      uint32_t       **pbinCnt,
00069                                      uint32_t       *pbinCnt_size,
00070                                      uint32_t       **pbinAvg,
00071                                      uint32_t       *pbinAvg_size );
00072 
00073 /* Compute avg, and remember best by storing the max values */
00078 int ph_histogram_data_gen_max( const uint32_t   nbins,
00079                                const uint32_t   depth,
00080                                const uint32_t   format,
00081                                const float      max_element_value,
00082                                const uint32_t  *binVal,
00083                                const uint32_t  *binCnt,
00084                                /* These are returned/altered parameters */
00085                                uint32_t        *binAvg,
00086                                phColor         *pmaxbin_color,
00087                                phColor         *pmaxbin_threshold,
00088                                uint32_t       **pmaxBin,
00089                                uint32_t        *pmaxBin_size,
00090                                uint32_t       **pmaxCnt,
00091                                uint32_t        *pmaxCnt_size,
00092                                uint32_t       **pmaxAvg,
00093                                uint32_t        *pmaxAvg_size );
00094 
00095 int ph_histogram_data_bin_regions( const uint32_t nbins,
00096                                    const uint32_t depth,
00097                                    const uint32_t format,
00098                                    const float    max_element_value,
00099                                    const uint32_t val_percent_cutoff,
00100                                    const uint32_t max_bin_breaks,
00101                                    const uint32_t *valarray,
00102                                    const uint32_t *cntarray,
00103                                    const uint32_t *avgarray,
00104                                    const uint32_t *maxBin,
00105                                    const uint32_t *maxCnt,
00106                                    const uint32_t *maxAvg,
00107                                    phColor        *pcolor,
00108                                    phColor        *pthreshold );
00109 
00114 int ph_histogram_data_compute( const uint32_t   op,
00115                                const uint32_t   nbins_one,
00116                                const uint32_t   binstep_one,
00117                                const uint32_t   binelems_one,
00118                                const uint32_t   nbins_two,
00119                                const uint32_t   binstep_two,
00120                                const uint32_t   binelems_two,
00121                                uint32_t        *binVal_one,
00122                                uint32_t        *binCnt_one,
00123                                uint32_t        *binVal_two,
00124                                uint32_t        *binCnt_two,
00125                                uint32_t        *binVal_out,
00126                                uint32_t        *binCnt_out  );
00127 
00128 #ifdef __cplusplus
00129 }
00130 #endif
00131  /* Histogram Functions */
00133 
00139 #define phHISTFILE_ALL 1
00140 #define phHISTFILE_BASIC 2
00141 
00142 /* ------------------------------------------------------------------------ */
00143 /* bins are organized as follows:
00144  *
00145  * [ bin0d0, bin0d1, bin0d2,...bin0dN, ...  binNd0, binNd1, binNd2.... ]
00146  *
00147  */
00148 /* ------------------------------------------------------------------------ */
00164 PHAPI(class) phHistogramData : public phLiveObject
00165 {
00166 private:
00167     /* bins and depth determine the array sizes */
00168     uint32_t m_binCount;
00169     uint32_t m_binStep;
00170     uint32_t m_binElems;
00171 
00172     phColor m_maxbin_color;
00173     phColor m_maxbin_threshold;
00174 
00175     phColor m_color;
00176     phColor m_threshold;
00177     
00178     uint32_t *m_binVal;
00179     uint32_t *m_binCnt;
00180     uint32_t *m_binAvg;
00181     uint32_t *m_maxAvg;
00182     uint32_t *m_maxCnt;
00183     uint32_t *m_maxBin;
00184 
00185     uint32_t m_binVal_size;
00186     uint32_t m_binCnt_size;
00187     uint32_t m_binAvg_size;
00188     uint32_t m_maxAvg_size;
00189     uint32_t m_maxCnt_size;
00190     uint32_t m_maxBin_size;
00191 
00192     phImage  m_image;
00193     uint32_t m_image_height;
00194 
00195     void init();
00196     int updateFromBins();
00197 public:
00198     phHistogramData();
00199     ~phHistogramData();
00200    
00201     phHistogramData(const phHistogramData &hist);
00202     
00203     int copy( phObject *copyto_obj );
00204     int swap( phObject *obj );
00205 
00206     int setData(uint32_t binCount,
00207                 uint32_t binStep,
00208                 uint32_t *binVal,
00209                 uint32_t *binCnt );
00210 
00211     int setData(uint32_t binCount,
00212                 uint32_t binStep,
00213                 phColor  maxbin_color,
00214                 phColor  maxbin_threshold,
00215                 phColor  color,
00216                 phColor  threshold,
00217                 uint32_t *binVal,
00218                 uint32_t *binCnt,
00219                 uint32_t *binAvg,
00220                 uint32_t *maxBin,
00221                 uint32_t *maxAvg,
00222                 uint32_t *maxCnt);
00223 
00224     int copy( phHistogramData &copyfrom );
00225 
00226     int setColor(phColor color){ this->m_color = color; return 0; };
00227     int setThreshold(phColor threshold){ this->m_threshold = threshold; return 0; };
00228     
00229     /* These get functions should only be used for private copies
00230      * of histogram data. Don't use this with an instance that is constantly 
00231      * being updated */
00232     uint32_t getBinCount()       { return this->m_binCount; };
00233     uint32_t getBinStep()        { return this->m_binStep; };
00234     uint32_t getDepth()          { return this->m_binStep; };
00235     phColor  getMaxBinColor()    { return this->m_maxbin_color; };
00236     phColor  getMaxBinThreshold(){ return this->m_maxbin_threshold; };
00237     phColor  getColor()          { return this->m_color; };
00238     phColor  getThreshold()      { return this->m_threshold; };
00239     
00240     uint32_t *getBinCntArray()  { return this->m_binCnt; }; 
00241     uint32_t *getBinValArray()  { return this->m_binVal; }; 
00242     uint32_t *getBinAvgArray()  { return this->m_binAvg; };
00243     
00244     uint32_t *getMaxBin()       { return this->m_maxBin; };
00245     uint32_t *getMaxAvgArray()  { return this->m_maxAvg; };
00246     uint32_t *getMaxArray()     { return this->m_maxCnt; };
00247     
00248     phHistogramData &operator =( phHistogramData &right );
00249     
00250     phHistogramData &operator +=( phHistogramData &right );
00251     //phHistogramData operator +( phHistogramData &right );
00252     
00253     phHistogramData &operator -=( phHistogramData &right );
00254     //phHistogramData operator -( phHistogramData &right );
00255 
00256     /* Sets the height for the auto generated image */
00257     int     setImageHeight      ( uint32_t height );
00258     int     autoGenerateImage   ( uint32_t height = 0 );
00259     int     generateImage       ( uint32_t height = 0 ); 
00260     phImage *getImage();
00261 
00262     void print_data();
00263     void print_stats();
00264 
00265     int save(const char *filename, int overwrite = 0);
00266     int load(const char *filename);
00267 };
00268  /* ImageProcessing */
00270 
00271 #endif /*  _PHHISTOGRAMDATA_H */




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:08 2007 for phission by  doxygen 1.4.4